Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages and disadvantages of using Ajax update panels in ASP.NET application

What are the advantages and disadvantages of using Ajax update panels in ASP.NET application. Is there any alternatives available to avoid the use of Ajax update panel?

like image 446
Sauron Avatar asked Jul 20 '09 05:07

Sauron


People also ask

What are the disadvantages of Ajax?

Any user whose browser does not support JavaScript or XMLHttpRequest, or has this functionality disabled, will not be able to properly use pages that depend on Ajax. Multiple server requests need more data consumed at the client-side. Failure of any one request can fail the load of the whole page.

What is Update panel in Ajax?

Introduction. 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.


2 Answers

Advantages:

  1. Easy to use and configure (Well, I don't know of any other advantages!)

Disadvantages:

See here and here
Now for the best part, the alternatives:

Use jQuery's built in support for Ajax to make GET/POST Ajax calls, it's very simple (simpler than the update panel I would say), and absolutely compatible with most browsers!
An example of using one of the many easy ways jQuery provides for doing Ajax calls:

  $('#anotherContainer').load('/Home/RegularAjaxResource');

This would simply call a server resource (RegularAjaxResource in this case) and display it's returned data on an UI element with id anotherContainer

like image 153
Galilyou Avatar answered Sep 23 '22 02:09

Galilyou


I agree with 7alwagy, except just want to add an important point.

You have to use the UpdatePanel if you want to update/change controls AND still work within the Webforms Postback model of state control, in particular, Viewstate.

For example:

if you explicitly use JS to update the values of a DropDownList control on the client, and you're using the built in Webforms Postback model, the changes you've made won't be picked up.

Essentially, if you're relying on the built in Viewstates, then you have to use the UpdatePanel. You can technically not use it, but you'll really have to fight agaisnt the framework to get things done.

If you're not relying on Postbacks or Viewstates, then you totally don't need the UpdatePanel.

like image 21
andy Avatar answered Sep 23 '22 02:09

andy