Showing posts with label updatepanels. Show all posts
Showing posts with label updatepanels. Show all posts

Wednesday, March 21, 2012

Is ASP.NET AJAX UpdatePanels are dangerous ?

Hi,

I am a big fan of using 'Update Panels'. Not because of the only simplicity but also bcoz of my belief on the AJAX framework.
But, at the same time lots of architects do say that, PageMethods [http://metasapiens.com/PageMethods/Tutorial/VS2005/] are more efficient than Update Panels.
Here is the link - ASP.NET AJAX UpdatePanels are dangerous.

http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/

After reading the page, I am quite suspicious on Update Panel and now think that really PageMethods saves perfomance overhead.But at the same time, simply by going thru few pages, accepting the same seems to be quite impractical.

Please let me know, is really PageMethods are more efficient than UpdatePanel. If yes, then please list me the things that cannot be done using PageMethods, which can be done by UpdatePanel.

Regards,

Arun

Hi,

dangerous is itself dangerous word in this context, but truth is that UpdatePanels, by design and due to their nature, pass a lot more stuff over the wire than PageMethods. Remember, they pass the changed markup, ViewState etc over the wire.

What the article/post says about it is true. However, it is always context dependant, is it an issue. Is the Page so big that async postback with UpdatePanel is unbearable? There are also ways to optimize things like reducing the unneeded ViewState, using multiple UpdatePanels to split the page to as-small-as-possible regions which need to be updated using UpdatePanel. E.g update only the parts which really need to be updated instead of passing everything you have on the Page. Using one UpdatePanel for entire page for example is not wise, if the page can be split up.


joteke:

using multiple UpdatePanels to split the page to as-small-as-possible regions which need to be updated using UpdatePanel. E.g update only the parts which really need to be updated instead of passing everything you have on the Page. Using one UpdatePanel for entire page for example is not wise, if the page can be split up.

I think it's important to keep in mind that even if you do break the page into multiple UpdatePanels, the entire ViewState is still sent to the server. On top of that, the Page and every single control in its control tree is reinstantiated, even if you're only visibly updating a tiny portion of the page.

The overhead associated with this can be relatively massive.


It would be nice to see if UpdatePanel could evolve so that its child controls would have viewstate field of their own (one per Panel), however that brings a lot complexity to the picture (especially from MS perspective) but also for developer to be explicit which Panels access each others child controls (that's why page now loads entire state because it must assume any control could be accessed).

While I'd use PageMethods too mostly today, I also like easiness of UpdatePanels and look for its evolution in vNext (meaning the one after Orcas/2008)


hello.

well, lets be honest: the updatepanel is a beautiful piece of engineering. having said that, i think that ajax is mostly done on the client, so major js,css, xml, etc is required. I'm not sure if changing viewstate is the way to go here. i'm thinking that what should be changed is the way we, developers, face our projects...

Is is better to use multiple UpdatePanels

I just switched from MagicAjax, where it was best to break the page up into as many AjaxPanels as possible to make the page go faster.

With Atlas is it preferable to put the whole page inside of an UpdatePanel, or to use multiple UpdatePanels, or UpdatePanels inside of other UpdatePanels to increase speed?

What I'm asking is, does Atlas automatically send least possible html back to the page, or do I need to try to have my UpdatePanels contain only the necessary parts of the page?

You probably want to have multiple updatepanels -- one for difference portions of the page. UpdatePanels support both an "always" and "conditional" mode of rendering. Conditional means it only renders if it has to (for example: a trigger fires or you manually call update on it, or a control within it caused the postback). A best practice would be to use conditional rendering to only send down the HTML you require.

Hope this helps,

Scott


Alright, thanks for clarifying that. I'll remember that next time before I wrap my entire masterpage in an update panel, and set it to always.Smile [:)]

Is it different to use serveral small UpdatePanels or use one UpdatePanel with entire page

How many data with processed on server and how many data will response to client?

I think multiple small UpdatePanel should surely be better.

SeeHERE.

dflying:

UpdatePanel just updatesALL the controls in its ContentTemplate from server, which may be very low efficient.