ASP.NET, AJAX, and JavaScript
-
Hi guys! I have had to use quite a lot of AJAX for the website that I am working on, but I am often faced with synchronizing control properties between the client and server. I started thinking about ways in which I could interact with the view state, but there are complexities involved with this (i.e. encryption and compression). I then realised, what if a second view state were to be constructed for client side use. I could create a JavaScript class which manages this view state, and a base class for all client-side controls which eases interaction with this client-side view state. I figure that the best way to serialize this information is with JSON (I use the JavaScript Prototype Framework for this). I haven't actually created this yet because there is a major problem that I wanted to address. Somehow I need to intercept the default ASP.NET "__DoPostBack" function so that I can add some serialization functionality for my client view state class. Any help would be greatly appreciated! Lea Hayes
-
Hi guys! I have had to use quite a lot of AJAX for the website that I am working on, but I am often faced with synchronizing control properties between the client and server. I started thinking about ways in which I could interact with the view state, but there are complexities involved with this (i.e. encryption and compression). I then realised, what if a second view state were to be constructed for client side use. I could create a JavaScript class which manages this view state, and a base class for all client-side controls which eases interaction with this client-side view state. I figure that the best way to serialize this information is with JSON (I use the JavaScript Prototype Framework for this). I haven't actually created this yet because there is a major problem that I wanted to address. Somehow I need to intercept the default ASP.NET "__DoPostBack" function so that I can add some serialization functionality for my client view state class. Any help would be greatly appreciated! Lea Hayes
I've been digging around and have just discovered the
Page.ClientScript.RegisterOnSubmitStatement
method. This method allows client-script code to be injected into the default ASP.NET__DoPostBack
method by means of an ASP.NET specific custom eventtheForm.onsubmit
. If the custom client-script code returns false, the post back is aborted. So, for my particular problem, I can use this functionality of ASP.NET to create a client-side equivalent of the server-side view state. Best regards, Lea Hayes