Well the page is already made, what I need to do is change some of the elements inside the page to be more mobile friendly. It is quite the task, since the web page is using DevExpress and is already made in a way that might be difficult to change. In this case, I'm trying to make the login page mobile friendly. I think I might end up making a new one, should it prove too difficult to change the existing one.
EDIT 1: I'm checking out this website:
http://www.formget.com/how-to-make-simple-responsive-form-for-a-website/#
It seems to do what I want, even though it is not DevExpress. I don't like DevExpress. It simplifies some things and complicates others. Maybe I can just use this for the parts that should be mobile responsive like the login.
EDIT 2: Decided not to use the resource above. It is a couple of CSS files, but the whole project is in DevExpress. I should figure out how to do it in DevExpress. It won't be easy, since I've read as much as I could on mobile response in DevExpress and there's not a lot to go on.
EDIT 3: Again changed my mind and went with bootstrap. I followed through the simple login I made not too long ago and it's turning out pretty good. I just need to test it in mobile to make sure it works as intended.
EDIT 4: Login is looking good, I just need to test it on mobile.
EDIT 5: My problem now is publishing the project, which is not letting me. I am using my local IIS to enter through my phone so I can see the result. To achieve that I had to set my IIS to a port and then open that port in the Windows Firewall. But the problem now is the project won't publish. The error I'm getting says Error : Copying file Inventory\Attachments\13_634703859621110000_Linchpin.htm
I'll see what I can get from that.
EDIT 6: I was able to fix the error. The problem was that even though in the folder that file didn't exist, in the Solution Explorer it did, along with many other "ghost" files. Thanks to this stackoverflow answer I was able to figure it out:
http://stackoverflow.com/questions/7969531/vs2010-wants-to-publish-a-non-existant-file-how-do-i-change-it
Now I'm getting an error related to the config file, but I'll figure it out eventually. If it becomes too much trouble I'll blog about it.
Tuesday, September 15, 2015
Web page won't show Bootstrap style
For some reason the web page I am publishing is not showing the Bootstrap style. The style is shown in the mobile browser and when I'm debugging, but when I try to access the page where I published it in ANY browser on my laptop, the Bootstrap style isn't shown. I intend to get to the bottom of this today. But I have no idea what could this be. If the style is shown in debugging and in the mobile browser, why isn't it shown in the normal PC browsers?
EDIT 1: SyntaxError: expected expression, got '==='
EDIT 1: SyntaxError: expected expression, got '==='
That's the error I'm getting. I don't know where those '===' are coming from, I check the line that's throwing the error and those equal signs are not there. The text is the same except for those equal signs.
EDIT 2: Well I forgot I didn't publish this, but I did solve it. The thing is, there was no problem at all. And I did refresh everything in the browsers, but what solved it was changing Internet connections. Weird as it sounds, but that's what did it.
EDIT 2: Well I forgot I didn't publish this, but I did solve it. The thing is, there was no problem at all. And I did refresh everything in the browsers, but what solved it was changing Internet connections. Weird as it sounds, but that's what did it.
Monday, August 31, 2015
Javascript function executing before jQuery finished loading data
It's been a while. Mostly because I haven't done anything serious that has taken me too much work to figure out. So here is the situation:
I'm bringing data to my web page from a Web Service and I store it in local storage, so I can use it offline. The problem? Some of that data is used to load dropdowns. But when I execute the dropdown loading function some of the data is not yet in the local storage. I assume the jQuery is executing asynchronous to the dropdown loading function, or any other Javascript function for that matter. I will have to find some way to confirm all the data is in the local storage, then execute the load dropdown.
EDIT 1: Well I solved THAT quickly! I had a function which parsed all the data then that function called three more functions which loaded the respective dropdown with their data as parameters. What I did was eliminate that function and only kept the three which were being called. The data I was loading there I loaded directly in the respective function. And, the most important, used a function in the .ajax jQuery called "complete", which executes after the success and failure. In each complete, I executed the dropdown loading function respective to each one.
I'm bringing data to my web page from a Web Service and I store it in local storage, so I can use it offline. The problem? Some of that data is used to load dropdowns. But when I execute the dropdown loading function some of the data is not yet in the local storage. I assume the jQuery is executing asynchronous to the dropdown loading function, or any other Javascript function for that matter. I will have to find some way to confirm all the data is in the local storage, then execute the load dropdown.
EDIT 1: Well I solved THAT quickly! I had a function which parsed all the data then that function called three more functions which loaded the respective dropdown with their data as parameters. What I did was eliminate that function and only kept the three which were being called. The data I was loading there I loaded directly in the respective function. And, the most important, used a function in the .ajax jQuery called "complete", which executes after the success and failure. In each complete, I executed the dropdown loading function respective to each one.
Friday, June 26, 2015
Deserialize JSON Object in C#
As soon as I'm done with this the project is basically done. I mean, the important part is sending and receiving data through the Web Service using JSON. I can already receive it, but I still need to send it. In my past entry, I explained how I communicated with C# by Javascript. Now, I receive a big string which is a "stringified" JSON array. What I need to do deserialize that data so that I can correctly separate the data and then INSERT it to the database. This is the code I have right now:
[WebMethod]
public void SyncToServer(string D)
{
Console.Write(D);
var jobs = JsonConvert.DeserializeObject<Job[]>(D);
Console.WriteLine();
}
The string D is the JSON I'm receiving. D has a string which is the JSON array. The class Job has the exact same fields that the JSON has, so it shouldn't be a problem. And that is the exact solution I've read in every place I've searched. But it's not working. The error I'm getting is the following:
UPDATE: I now copied the JSON array string to a variable and tried executing the same code, but no change. I suspect it has to be the way I'm doing it is incorrect. I still have to keep investigating.
UPDATE 2: I tried making the JSON in the variable a JSON object with the whole array as a parameter, but it's still not working.
UPDATE 3: Wow... The problem was the JSON. It was incorrectly formatted, it had a couple of extra brackets that didn't go there. That's why it wasn't recognizing the format. Now that I've managed to figure out where the flaw was, time to go back to the Javascript and find out where exactly is it going wrong in creating the JSON.
UPDATE 4: GOT IT! In the Javascript I changed the way I was writing the JSON in the localstorage. If the localstorage was empty, I pushed the object into an array then placed it on the localstorage. The problem was that it was inserting the whole object as an array, and I needed to insert just the object. Success!
[WebMethod]
public void SyncToServer(string D)
{
Console.Write(D);
var jobs = JsonConvert.DeserializeObject<Job[]>(D);
Console.WriteLine();
}
The string D is the JSON I'm receiving. D has a string which is the JSON array. The class Job has the exact same fields that the JSON has, so it shouldn't be a problem. And that is the exact solution I've read in every place I've searched. But it's not working. The error I'm getting is the following:
An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user codeI will continue to try and deserialize it.
Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Job' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
UPDATE: I now copied the JSON array string to a variable and tried executing the same code, but no change. I suspect it has to be the way I'm doing it is incorrect. I still have to keep investigating.
UPDATE 2: I tried making the JSON in the variable a JSON object with the whole array as a parameter, but it's still not working.
UPDATE 3: Wow... The problem was the JSON. It was incorrectly formatted, it had a couple of extra brackets that didn't go there. That's why it wasn't recognizing the format. Now that I've managed to figure out where the flaw was, time to go back to the Javascript and find out where exactly is it going wrong in creating the JSON.
UPDATE 4: GOT IT! In the Javascript I changed the way I was writing the JSON in the localstorage. If the localstorage was empty, I pushed the object into an array then placed it on the localstorage. The problem was that it was inserting the whole object as an array, and I needed to insert just the object. Success!
Thursday, June 25, 2015
Sending JSON to C#
I'm trying to POST a JSON from Javascript to a C# asmx. Apparently there is an error trying to deserialize the JSON. I've already tried creating a class with the same parameters, but somehow it didn't work. I also tried deserializing the JSON to a string List, but to no avail. The JSON is an array, and it comes in string format. I'm trying to get into it. We'll see how it goes.
UPDATE: So the error I was getting has changed. Originally I had this:
Type 'System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for deserialization of an array
Now, I'm getting this:
I would like to thank the following link for providing some light to my problem: http://blog.dj-djl.com/2013/05/type-systemcollectionsgenericidictionar.html
Now, according to that link, one of the problems I had was placing the JSON Array in a simple JSON object. So what I'm assuming is that you can't send it as an array, but you can send it as JSON Object and make the array a parameter. I'm not sure if that makes sense as I wrote it.
As I wrote this, I realize that the class I'm using to get the JSON is not declared as an array. This could be why I'm getting that error. I will verify and update.
UPDATE 2: Changed it to array but it didn't work. I'm going to keep verifying some things but I might just try to use a string list instead of the object I created for the JSON to get the data. Be back in a few.
UPDATE 3: Changed the name of the object to match the name of the parameter in the JSON and to no avail. BUT
The error message changed. It can't be converted to the type of object I defined. Why? I'm not completely sure, but I have a feeling it's because the array of data that I need is inside a parameter.
UPDATE 4: Changed the object to a string array and I still get an error.
UPDATE 5: FUCKING GOT IT!!!!! Ok so what happened was that when I placed the JSON Array inside a JSON parameter, I no longer needed to get a string array, but rather one string which is all of the array. Now I get all of the array in string format. What follows is parsing that string to get the information I need. For now I'm ending it here.
UPDATE: So the error I was getting has changed. Originally I had this:
Type 'System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for deserialization of an array
Now, I'm getting this:
- Invalid web service call, missing value for parameter: 'job'."
- StackTrace: " at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) ↵ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)"
I would like to thank the following link for providing some light to my problem: http://blog.dj-djl.com/2013/05/type-systemcollectionsgenericidictionar.html
Now, according to that link, one of the problems I had was placing the JSON Array in a simple JSON object. So what I'm assuming is that you can't send it as an array, but you can send it as JSON Object and make the array a parameter. I'm not sure if that makes sense as I wrote it.
As I wrote this, I realize that the class I'm using to get the JSON is not declared as an array. This could be why I'm getting that error. I will verify and update.
UPDATE 2: Changed it to array but it didn't work. I'm going to keep verifying some things but I might just try to use a string list instead of the object I created for the JSON to get the data. Be back in a few.
UPDATE 3: Changed the name of the object to match the name of the parameter in the JSON and to no avail. BUT
- Message: "Cannot convert object of type 'System.String' to type 'Job[]'"
- StackTrace: " at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) ↵ at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) ↵ at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams) ↵ at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) ↵ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)"
The error message changed. It can't be converted to the type of object I defined. Why? I'm not completely sure, but I have a feeling it's because the array of data that I need is inside a parameter.
UPDATE 4: Changed the object to a string array and I still get an error.
UPDATE 5: FUCKING GOT IT!!!!! Ok so what happened was that when I placed the JSON Array inside a JSON parameter, I no longer needed to get a string array, but rather one string which is all of the array. Now I get all of the array in string format. What follows is parsing that string to get the information I need. For now I'm ending it here.
Subscribe to:
Posts (Atom)