Jul 22nd, 2009 | No Comments

Another one of those problems that can stump you for a while. I often make backups of files as I progress and sometimes leave them in the website folder, this was fine with classic ASP but as I have found with ASP.Net can cause all sorts of problems.One issue I was having was trying to reference a component in my aspx page from the codebehind page and seeing the following error when trying to reference a label control:

“Label2 does not exist in the current context”

So I found that the problem was even though I renamed one of my old files it still contained the class that my codebehind was referencing (i.e. the class names were still the same) – and therefore was not seeing the newly added Label control to my new code.Shame the compiler doesn’t realise the duplication and give some indication.

Lesson: Remove any backed up files from the web folder and/or build directory to avoid pain )

Written by Ajay Matharu

July 22nd, 2009 at 11:24 pm

Jul 15th, 2009 | No Comments

Recently our team came across a situation where our job was to retrieve ArrayList in a page requested by flex application using HttpService.Which are accessed using Request[keyName]

Request objects always returns data in string format, so there was no point in trying that solution, so we were looking for some reliable and optimal solution. Googling around I came across JSON (Javascript Object Notation).JSON can be used in various languages, you can find the list of langauges and the resources requied to use JSON over here.

JSON allows us to serialize a object and send across a page in string format.All we need to do is to perform Deserialization on the requested page.

This is the sample code which demonstrates the use of JSON to send arraylist to another page.

The code below contains 2 arraylist which need to be send on another page.The arraylist are serialized and sent to different page with the help of querystring.

ArrayList list = new ArrayList();
ArrayList list1 = new ArrayList();
list1.Add("one-one");
list1.Add("one-two");
list1.Add("one-three");
list1.Add("one-four");
list.Add(list1);
list.Add("two");
list.Add("three");
string arrayList = JavaScriptConvert.SerializeObject(list);
Response.Redirect("Process.aspx?list="+arrayList);

The code below Deserialize and typecast the object to JavaScriptArray.

string arrayList = Request["list"];
JavaScriptArray list = (JavaScriptArray)JavaScriptConvert.DeserializeObject(arrayList);

You can download sample code from here.

Enjoy Coding :)

Written by Ajay Matharu

July 15th, 2009 at 9:20 pm