Download C# Javascript Wrapper Sample

I have done a small sample on how to use the C# Javascript Wrapper in web applications to get new data without the need of a postback. Feel free to download the sample from http://schwarz-interactive.de/download/clientcallback.zip. Unzip the file, create a virtual IIS folder and start the application. The methods used in the default.aspx can be found in default.aspx.cs. They are marked with an attribute (MS.Web.JavascriptMethod). Currently you can use bool, int, string and XmlDocument for the return value, more later.

Published Thursday, March 03, 2005 9:13 PM by Michael Schwarz

Comments

# re: Download C# Javascript Wrapper Sample

Thursday, March 03, 2005 3:26 PM by Marc
Is this the same code that in one of your last posts?

# re: Download C# Javascript Wrapper Sample

Thursday, March 03, 2005 4:24 PM by Michael Schwarz
Yes, it is the same code that is used on http://beta.schwarz-interactive.de.

# re: Download C# Javascript Wrapper Sample

Thursday, March 03, 2005 5:41 PM by Charles Chen
Michael, have a look at JSON (Javascript Object Notation). It's interesting because Javascript can natively operate on it, it's well structured, and you can easily parse it and rehydrate a class. You'll also find that it tends to be more compact and explicit than XML serialization.

JSON Main Site:
http://www.crockford.com/JSON/

My examples of JSON with ASP:
http://www.charliedigital.com/_workshop/asp_json.aspx

Keep in mind that my ASP examples are just to demonstrate the cool server side stuff that you can do with it. Everything that I do in the ASP examples also works client side (obviously with the exception of Response.Write) since JSON *is* Javascript.

# re: Download C# Javascript Wrapper Sample

Thursday, March 03, 2005 5:50 PM by Michael Schwarz
@Charles: I know this already but did not worked with it. In my work I have to do a lot with XMLs. Therefore I am using XML instead of the JSON. I will have a look on it later...

# re: Download C# Javascript Wrapper Sample

Thursday, March 03, 2005 6:26 PM by Charles Chen
Well, what is of interest in this case is that your client side Javascript can work directly on the string (a serialized version of your object) without translation/parsing on the client side using XML DOM. So you could write a JSONSerializer class and serialize object instances to strings which you could access using DOM on the client using eval() to create a Javascript object. Then you could directly work on the object on the client side and send the string back to the server.

Just a thought :)

You can do a lot of interesting htings with JSON and OOP.

# re:Download C# Javascript Wrapper Sample

Saturday, April 09, 2005 11:42 PM by TrackBack
^_^,Pretty Good!