Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS UpdatePanels not really AJAX?

I keep hearing that the server side ASP .NET AJAX controls (like UpdatePanels) are not truly AJAX though they seem like it, because rendering is not completely on the client side. I'm trying to understand this with more clarity. Could someone elaborate?

Thanks...

like image 632
Prabhu Avatar asked Jul 12 '10 23:07

Prabhu


People also ask

What is UpdatePanel Ajax?

UpdatePanel controls are a central part of AJAX functionality in ASP.NET. They are used with the ScriptManager control to enable partial-page rendering. Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated.

Can we use nested UpdatePanel in Ajax?

To nest UpdatePanel controlsIn the AJAX Extensions tab of the toolbox, double-click the ScriptManager control to add it to the page. In the toolbox, double-click the UpdatePanel control to add an UpdatePanel control to the page.

What is difference between AsyncPostBackTrigger and PostBackTrigger?

The AsyncPostBackTrigger “wires” up these controls to trigger an asynchronous post back. Conversely, controls declared inside an update panel will trigger an asynchronous call by default. The PostBackTrigger short circuits this, and forces the control to do a synchronous post back.

What is the purpose of AsyncPostBackTrigger in the UpdatePanel?

Use the AsyncPostBackTrigger control to enable controls to be triggers for an UpdatePanel control. Controls that are triggers for an update panel cause a refresh of the panel's content after an asynchronous postback.


1 Answers

UpdatePanels came out fairly early in the AJAX cycle, and they're heavy (they can emit around 100-300k of JavaScript). Behind the scenes, UpdatePanels post the entire page back to the server via a JavaScript XMLHttpRequest. The new page is generated with the normal page lifecycle just like a postback, but only the parts that live inside the UpdatePanel (plus the parts necessary for updating ViewState and so on) are sent back to the client. From there, the markup is inserted without a visible flash or interruption of page state.

Most competing AJAX tools lean towards super lightweight implementations that let you ship or generate a small chunk of HTML via Javascript, and I would say that's the dominant direction today, especially outside the ASP.NET world.

The difference in total amount of data sent across the wire is huge -- see the link below. In low-traffic situations it might not make a bit of difference, but in the case of a site like StackOverflow, it would show up on the bandwidth bill for sure.

All that said, I don't think it's fair to say that UpdatePanels are not actually AJAX, since they do ship HTML around via asynch JavaScript -- it's just that there's a gigantic, often cumbersome framework on top. UpdatePanels get a bad rap sometimes, but they provide a brilliantly simple developer experience. I've often found them useful in low-traffic situations.

Update: Here is an article (old but still valid) that examines the payload UpdatePanels ship to and from the server. It also goes into Page Methods, which is a lightweight, Web Service-based alternative to UpdatePanels. This is an oft-overlooked part of Microsoft AJAX.

like image 55
12 revs Avatar answered Sep 22 '22 00:09

12 revs