D'Arcy from Winnipeg
Solution Architecture, Business & Entrepreneurship, Microsoft, and Adoption

Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

Thursday, September 6, 2007 7:15 AM

There's a great MSDN article by Jeff Prosise that talks about the pros and cons of using the Microsoft AJAX update panel compared to other options (like web services and page methods). A quick excerpt:

"For better or for worse, the UpdatePanel control is the darling of the ASP.NET AJAX community. I say "for better" because UpdatePanel makes partial-page rendering shockingly easy and "for worse" because its simplicity and ease-of-use come at the cost of efficiency and, ironically, bandwidth.

While UpdatePanel brings AJAX magic to ordinary Web pages, it doesn’t bring the efficiency we normally associate with AJAX. Did you know, for example, that when an UpdatePanel control performs an asynchronous AJAX callback to the server to update its content, the request contains everything a conventional ASP.NET postback contains, including view state? Most developers assume that AJAX eliminates view state. That’s not the case, though, with UpdatePanel’s brand of AJAX."

D




Feedback

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

If you want to see something *really* cool, check out the size of the AJAX related js files!! 9/6/2007 7:42 AM | Justice~!

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

Yeah, I have no doubt those are pretty huge...although that I can stomach since it *should* just be a one-time download unless the files change and they get updated.

And considering how much of the gruntwork is taken out of doing naked AJAX calls, I'd expect those files to be huge anyway.

D 9/6/2007 7:50 AM | D'Arcy from Winnipeg

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

Hey D

I was going to comment earlier...(in the middle of a launch though :)..

I've been using the manual web service calls of the Microsoft AJAX library and it's still pretty simple to use, all things considered. Of course, doing it this way you need to know how to do-it-yourself replacement of html on the page, but that is simple enough to do too (getElementById, and innerHTML are your friends :P)

Of course all of this could be abstracted a little further into more convenience objects.....perhaps even manually compile a web part or user control on the server in the web server call and return the rendered html for that one piece...I seem to remember two cool guys talking about exactly this at some point a little while ago......one even promising to build such a thing but then as usual got bogged down with work.... 9/6/2007 4:40 PM | Shaneo

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

We've been playing with the page-method option for doing remote calls as well...pretty much the same thing as the web-service idea, but different access-scope. Super easy now that I know how, although there's still javascript to write on the client...but that's a tradeoff I'm willing to take if it means better performance.

D 9/7/2007 12:57 AM | D'Arcy from Winnipeg

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

This highlights my growing concern with WebForms. Everything is turning into a control and with out taking hte time to dig deeper we really don't know what we are trading in performance for this easy-of-use (same reason I am warey of Ruby).

I'll stick with my custom AJAX lib at a packed 1.8K

The thought crosses my mind every once and a while, when dealing with performance problems at work, usually realted to viewstate and 3rd party controls, that I should just whip up a C CGI library and really enjoy application performance. 9/7/2007 5:04 AM | Justin

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

Steps to resolve performance issue with Microsoft AJAX.Net

1. Use <asp:UpdatePanel> panel only for those portion which will be changed by AJAX.
Explanation: Some developers use the UpdatePanel for the whole page, not for those portion which will be changed by Ajax. This is wrong.
Example: You are using a repeater and inside this repeater, you have your HTML content & one ASP.Net button. And you want to use Ajax for this Asp.Net button. Now some developers use UpdatePanel for the whole repeater which is wrong. You should use UpdatePanel only for this Asp.Net button.

2. Use Page.IsPostBack
Place postback check for those tasks which are accomplished only once at the time of page load.

3. Use ScriptManager1.IsInAsyncPostBack
Place Asyncronous postback check for those tasks which are accomplished either at the time of page load or normal postback; but not at the time of ScriptManager (AJAX) postback.

4. Use EnableViewState="false"
Minimize the page viewstate upto the possible point.

5. Enable Compression & Caching for the AJAX requests. Use the following settings in web.config file:
<system.web.extensions>
<scripting>
<scriptResourceHandler enableCompression="true" enableCaching="true" />
</scripting>
</system.web.extensions>
7/8/2008 12:14 AM | Ankur Goel

# re: Microsoft AJAX Update Panel - Great on Looks, Poor on Performance

Great tips on ASP.NET AJAX.
Few more tips might be:-

Turn of viewstate for controls that did not need it. Don't turn of at page level, cause you fall back to ASP, losing point of using ASP.NET

User SessionState instead. However, becareful with Server resource. Clear sessionState as fast as possible.

Question, I don't know is there a way to tune the huge Javascript. Is it only the first load that cause problem??

ASP.NET AJAX still way to go, it give developers a semi-window form development. Calling Page_Load, Page_LoadComplete and other methods for each post back is really a performance problems.
Not like window form, form load means form load, it is loaded once. For unload means the form is gone. In web simply means user leave the page or closed browser (this is not the case).

Confusing ASP.NET page load cycle...


11/10/2009 8:20 PM | Trevor Wong

Post a comment