Tuesday, January 05, 2010

JSON - Jquery

JSON & Jquery might have stormed well in the AJAX/WS world. But the right documents are missing. I was banging myu head for a few hours, on how to get a json object from a codebehind:

I was building a JSON object:{name:myvalue}

Tried all ways and it never workd in the Ajax method:

$.post("test.aspx?tbg=yu", $("#form1").serialize(),
function(data) {
alert(data.name); ---->Always returned undefined. In firebug it was not showing at all.


The Right solution is {name:'myvalue'}. This ******ing >>>>'<<<<< style="font-style: italic;">-Happy Hacking

Monday, January 04, 2010

String to Stream in C#

There are multiple ways, best two:

Us the System.IO.StringReader.

//Good when you want to preserve the UTL character
byte[] bytesFromString = System.Text.Encoding.UTF8.GetBytes(xml);
System.IO.Stream stream = new System.IO.MemoryStream(xmlBytes);