I have an Entry Form and a GridView on the same page. Selecting a row from the GridView populates the TextBoxes in the Entry Form above it with all the entries of the GridView row.
When this page opens and any row is selected from the GridView, I could see a lot of View State data being sent to the server with each AJAX request. I selected View Source option of the browser to check this. I tried disabling the View State on top of the page by using: EnableViewState = "false", but my application stopped performing correctly.
On selecting any row from the GridView, error is generated and so I re-enabled the View State.
Is there any optimized way to use View State and keep AJAX requests small? Anything related to View State compression as well?
I am using ASP.NET 2.0.
From the moment that you use
UpdatePanel
, out of the box ajax call you are stick to send all form post data, including the big view state.You have two ways, one is to make custom made, ajax call that are focused only to the change that you control, and not the full post back that UpdatePanel do.
The other way is to minimize what page send back with each post back, and compress the viewstate.
To compress the viewstate I suggest some pages here that have ready to use source code.
http://www.codeproject.com/Articles/14733/ViewState-Compression
http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx
http://www.bloggingdeveloper.com/post/How-To-Compress-ViewState-in-ASPNET-20-ViewState-Compression-with-SystemIOCompression.aspx
and a similar question that I did: How to limit the number of post values on UpdatePanel?