Jonas Stawski

Everything .NET and More

UpdatePanel Efficiency

So I am writing an application with ASP.NET AJAX and using the update panel to update certain controls. So there I was creating the page without any AJAX and with normal postbacks and when I was finished I just added a script manager and an update panel and voila everything works wonderfully. So I told myself: "This is so easy to implement that there must be some side effects." Usually when something is very easy to implement and so generic efficiency is hurt. So I did a search on updatepanel efficiency and I came across 2 articles: Jeff Prosise's Update Panel Tips and Tricks and Nick Riggs' Update Panel's Update Mode Property Efficiency. I must say I was not surprise with Jeff's statements on using update panels and the efficiency hits, but I was surprised with Nick's findings on using the different update modes. So being the skeptical person I am I go to the source when it comes to AJAX, the good all mighty of AJAX, the know-it-all of AJAX, the one and only one DevTheo: Mr Jay Kimble. Indeed he did confirm Nick's findings. The reason? When using the update panel and an update is fired the whole page life cycle is re executed (just like a post back) and for that you need the viewstate, which usually composes most of the page's weight.

So in the words of the all mighty: "UpdatePanel should be used if you are in a hurry or if there is no other way." When is there no other way? When you're dealing with very complex controls like the grid view or the report viewer. When should I not use the update panel (this is for the developers that really care about performance)? When you need to get very simple things, like a value given certain values. For example when you want to select a state given a zip code. So how would you do it? You would use Page Methods and call those page methods from JavaScript. When you get the returned value (in this case the state) you use javascript to select the correct state.

Happy Programming!

Add comment

biuquote
Loading