Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
792 views
in Technique[技术] by (71.8m points)

asp.net - Limiting view state information on AJAX calls

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...