Regarding UpdatePanel internal?

2020-07-26 11:10发布

问题:

suppose i have many heavy control is on the page. as for example i have three gridview populated on the page and one gridview & button is inside the updatepanel. from this scenario we can understand that there will be huge viewstate on the page. so i want to know that if i click on button inside the updatepanel then all the viewstate will be submitted to server during partial postback or not. if huge viewstate submit to server and comes back to client then what is the advantage of partial postback because response time will be slower. so tell me how could i tune up the code that only required things will only submit to server. discuss the partial postback concept in detail as a result we can take right action to have good performance. thanks.

回答1:

+1 to geek!

If you are concerned about the performance of your page(s), I would also recommend using ListView instead of GridView:

http://www.4guysfromrolla.com/articles/122607-1.aspx

http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx

http://basgun.wordpress.com/2007/12/27/listview-control-in-aspnet-35-1/

http://basgun.wordpress.com/2007/12/28/listview-control-in-aspnet-35-2/

http://basgun.wordpress.com/2007/12/29/listview-control-in-aspnet-35-3/

http://basgun.wordpress.com/2007/12/30/listview-control-in-aspnet-35-4/

You can also visit Matt Berseth's blog to see how ListView can get very handy (and neat) for different types of development scenarios:

http://mattberseth.com/blog/listview/



回答2:

it's important to keep in mind that an UpdatePanel's partial postback invokes a full page life-cycle on every single async request.

Please check out following links for pros and cons of the update panel.

Why ASP.NET AJAX UpdatePanels are dangerous

Why you should not place your whole site in an UpdatePanel

Are you making these 3 common ASP.NET AJAX mistakes?



回答3:

so i want to know that if i click on button inside the updatepanel then all the viewstate will be submitted to server during partial postback or not

Yes, it will. The entire page's view state is transmitted (in its entirety) to the server on partial page postback, and the new view state is sent back (in its entirety) from the server back to the client on response.

I'd suggest you use a tool like Fiddler to examine the HTTP traffic between the browser and your server when making a partial page postback. This article provides an overview of using Fiddler - Troubleshooting Website Problems by Examining the HTTP Traffic.

In short, the UpdatePanel is meant as a quick and dirty way to get partial page postbacks without having to worry about client-side script or writing logic on the server to specifically handle a partial page postback. Such simplicity comes at a cost, as you've discovered. :-)

For more control over the content that is sent to and from the server on a partial page postback you need to write client-side script and create server-side methods or services to handle the Ajax requests. These articles offer various techniques for providing such functionality:

  • Accessing JSON Data From an ASP.NET Page Using jQuery
  • Using Ajax Web Services, Script References, and jQuery
  • Using WCF Services with jQuery and the ASP.NET Ajax Library


标签: asp.net