Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Sunday, October 30, 2016

I am trapped in the UpdatePanel trap

I am trapped in the UpdatePanel trap


I have a very big problem. I am making a CRM (Costumer Relationship Management) System in ASP.NET 3.5

I have based my entire project on DevExpress.com controls and the use of UpdatePanels.

Now one of my pages, which is a central page in the whole system, contains a very big amount of possibilities and therefore a big amount of UserControls.

Now my problem is that it's getting really really slow because of the fact that UpdatePanels are reposting the entire page and not only the update panel. We are talking sometime 3-4 seconds before a popup window appears :(

Is there any way I can refactor this entire system away from UpdatePanels without breaking my neck? Are there anyway I can optimize my use of UpdatePanels?

The ViewState is also absolutely giant.

Any good ideas are welcome...

Answer by joshb for I am trapped in the UpdatePanel trap


There's no way to get around posting the entire page using UpdatePanels. In lieu of redesigning the app here are a couple things I'd try:

  1. Disable viewstate for any controls that don't need it
  2. Set the UpdateMode="Conditional" for your user controls. This won't get around posting the entire page but it will cut down on rendering time a little. Only the content for the specific UpdatePanel will be updated in the browser.
  3. Make sure your user controls have short IDs. The way ASP.NET webforms names controls in the html these IDs get repeated quite a bit if you have a lot of server controls. Same goes for naming master page placeholders. I once cut a large page to half the size by renaming user controls and placeholders.

Answer by Adam Ralph for I am trapped in the UpdatePanel trap


You'll have to replace some of the postbacks contained in your update panels with real AJAX calls, i.e. send only the data that is required for the action to the server and get back only what's required to update the view, getting rid of the postback and the UpdatePanels.

(You'll notice my use of the terms 'action' and 'view' - yes, I am an MVC fan. The situation you are in is typical of the mess that is easily got into using WebForms and the ASP.NET AJAX controls.)

Answer by kervin for I am trapped in the UpdatePanel trap


  • I must be missing something. Why is your updatepanel is reloading the entire page. The point of an updatepanel is to refresh only what is in that panel, isn't it? Thanks for the explanation. I guess we're talking about reposting the page and not redrawing the panel as I thought.

  • Try turning off ViewState, especially for grids.

  • What kind of control is most common on your page? Try replacing those with your own lightweight UserControl or Server Control that does not use ViewState or ControlState

Answer by Greg for I am trapped in the UpdatePanel trap


Since you're a DevExpress user, you might consider taking a little time to learn their CallbackPanel which will allow you to do asynchronous processing without the overhead of the UpdatePanel.

Alternatively (someone please correct me if I'm wrong) but if all of the postbacks are asynchronous (i.e. in an UpdatePanel), wouldn't it be theoretically possible to disable ViewState for the entire page (in the Page directive) without negative consequences? You'd have to test it completely off course, but it's worth a shot.

Answer by The real napster for I am trapped in the UpdatePanel trap


For all Interested I want to add a solution on how to get rid of the Viewstate data on clientside. It does give the server an extra load but if you are in the same situation as me and have a lot of server power and need to take the load of the clientside this is nice.

Let all your pages Derive from BasePage.cs looking like this

public class BasePage : System.Web.UI.Page  {      protected override void SavePageStateToPersistenceMedium(object viewState)      {          string vsKey = String.Format("VIEWSTATE_{0}_{1}_{2}", base.Session.SessionID, Request.RawUrl, DateTime.Now);          Session.Add(vsKey, viewState);          ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", vsKey);      }        protected override object LoadPageStateFromPersistenceMedium()      {          string vsKey = Request.Form["__VIEWSTATE_KEY"];          return Session[vsKey];      }  }  

Now you have a key to the viewstate data session instead of the viewstate in your code...

Works like a charm for me on a website with 1000-1200 daily visitors as well.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.