开发者

ASP.NET - how to make AJAX request to the server without getting response with the information for all the update panels I have?

Fo开发者_开发百科r example, I have three UpdatePanels on the page. I click a button, and I get pretty long response, that contains all the data for the three UpdatePanels, the viewstate string.

I want to optimize my query and receive response like "ok" or "not ok". How can I do that?


The short answer is that with MS Ajax and especially UpdatePanels, you can't.

The long answer:

The core of UpdatePanels is that they do a full post, and the full page lifecycle runs for whatever controls they contain, and they are able to parse out the portions of the reponse that pertain to their individual viewports on the page and update just those portions.

You can reduce the amount of data significantly by turning off ViewState for controls that don't need it. Another tip is to set the UpdateMode property of your Panels to "Conditional", so that all the update panels on the page aren't involved in every post. If you are posting from one panel and the response just updates that panel, then there is no need to transfer data about the controls in the other panels.

Read here for Update Panel tips and tricks to get better performance out of them.

If you really want to do just simple messages with your posts, I would look at using jQuery and its ajax/post methods to post to alternate pages or webservices. MS Ajax is designed around the postback architecture though, so while it's very convienent, you can't escape the overhead of it easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜