Ajax or UpdatePanel?

Inside the web application that we are developing, there is a time during which the user makes a search, providing some parameters (this is a reservation system, therefore "parameters" = 2 dates).

Then the hidden table (or better, empty) is populated with the query results.

Now my problem arises: is it better to use the AJAX call for the WebMethod or just leave the search button inside the UpdatePanel and update it on the server side?

In this post , Encosia points out that everything in the panel is updated every time an asynchronous postaback is executed.

So, given the fact that this application should be as fast as possible, and should use the lowest level of bandwidth, I went for the AJAX approach.
So I reduced it from 40-60KB to ~ 1KB (MAX!) Every search.

Doing "Search Button Click" β†’ Ajax call in WebMethod β†’ ​​Read JSONed and JQuery embedded in HTML inside table.

However, there are some problems with this approach, with more complexity to maintain the code (client side performance is not a big issue, it takes ~ 12ms to build the table).

+2


source to share


2 answers


I don't think I have a question here.

UpdatePanel is very easy to use / abuse / maintain, but effectively sends out the entire page asynchronously.



AJAX can be a little harder to maintain / involves more customization / code templates, but sends and receives less data and therefore uses less bandwidth. It should be more efficient than UpdatePanels, but whether or not it matters depends on a number of different factors (number of controls, page size, ViewState size, etc.).

Choice is what works best for your situation. What are the priorities of the app feature? If performance / throughput exceeds maintenance costs, go for AJAX. If maintenance and development speed are important, it might be UpdatePanel. If this is an intranet application, I would probably be less concerned about using UpdatePanels.

+3


source


If you have a choice, use PageMethods with jQuery . In the long run, you will be much happier. UpdatePanel will improve since ASP.NET 4.0, but is still inferior to jQuery and PageMethods.



+1


source







All Articles