ViewState and Scripting

Apress eBooks · 2006

The ASP.NET Framework provides a rich set of features for leveraging client-side functionality, including JavaScript. The ViewState and ControlState features use HTML hidden input to store state information on the client, which saves you from writing a lot of redundant boilerplate code. However, you must carefully monitor ViewState because it can quickly bloat your requests and responses. Version 2.0 increases the efficiency of the hashing algorithms in use to generate the ViewState value, decreasing the size of the value stored in the hidden input. In some situations, the ViewState size will still cause an unacceptable performance hit; in these cases, you have the option of replacing the location where the ViewState value is stored with one of your choosing (like Session, Cache, or a database). ASP.NET script-generation features have been aggregated and extended via the services the new ClientScript object provides. This object, a property of the Page object, exposes many methods you can use to generate JavaScript, and to avoid sending duplicate blocks of JavaScript to the client. There is a powerful new facility for doing out-of-band callbacks from the client to the server, which allows you to do partial page refreshes and avoid the overhead of a full postback to the server.

Read the paper · More papers on PaperTik