views:

557

answers:

5

Hi

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

+5  A: 

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.
joshb
LOL I did not consider the naming issue, although it is most definately there.. yes they get repeated a lot but I hate short not specific names... now I just have to consider if I hate slow loading even more..
The real napster
You might want to clarify this: "Only the specific user control will be updated on the screen." It should probably be "Only the specific UpdatePanel ...". You may also want to note that only the necessary panels are being sent to the client as well, as opposed to the whole page.
Ryan Versaw
A: 

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

AdamRalph
It's easy to be a big fan on of the new kid on the block :) I'm sure it's easy to write messy code in either framework.
kervin
Yes, that's definitely possible. The problem in WebForms is that a 'Hello World' page already looks messy!
AdamRalph
A: 
  • 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
kervin
UpdatePanels only refresh the content inside the panel, but the entire page lifecycle gets executed - which means that viewstate for all the controls gets sent to/from the server.
DDaviesBrackett
Thanks for the explanation. So it's really a ViewState problem. ViewState/ControlState are bugs :) I disable them whenever possible.
kervin
+1  A: 

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.

Greg
I will give this a try, the best suggestion so far..
The real napster
A: 

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.

The real napster