• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1549
  • Last Modified:

Slow Ajax postback - too much data?

This is complicated...

I have a repeater and in each item I have a table that contains an ImageButton.
When the ImageButton is clicked, I am using Ajax to populate another table within the appropriate repeateritem so that I can prompt the user for more information. This table-to-be-populated sits inside an UpdatePanel.

Here's the code for the updatepanel:

        <asp:UpdatePanel ID="upd1" runat="server" UpdateMode="Conditional">
        <asp:AsyncPostbackTrigger ControlID="imgBespoke" EventName="Click" />
            <asp:Table ID="rtbDetails" runat="server" CssClass="subtable"></asp:Table>

Clicking the imagebutton sets a hiddenfield in the relevant repeateritem to "y" and then causes a postback, and it's actually in Page_Load that I then loop through all repeateritems, looking for ones where the hiddenfield is set to "y". If so, I find the table-to-be-populated (rtbDetails) and then create and add the new cells, rows and fields (all 55 of them).
I do this in Page_Load because I need to maintain the ViewState of my dynamically created fields as I need to know what the user puts into them - by putting in Page_Load they are re-created each postback in the same way.

Believe it or not, it works! The table is populated with the dynamic fields, I can retrieve the values on postback and all is splendid. Until however I moved it to our on-line development server, and now there's a 10 seconds delay between clicking the ImageButton and Ajax doing its bit once there's more than about 80 rows in the repeater. As this only happens on the remote server, I presume the delay is a download of Ajax info that is then used to update the page.

Why is it sending so much? I thought it would only send the necessary code to update the relevant UpdatePanel?

Is there something I'm missing? Can I meaningfully track what is being sent back from the server without digging into packet sniffers etc, and more importantly, can I restrict it?

Incidentally, the reason I'm trying to do this is that if I pre-render all of the 55 fields per row and hide them, the whole page expectedly becomes slow to respond when there are many rows.

Any help very much appreciated.

ASP.NET 2, Win 2003.
Both IE 7 and Firefox
1 Solution
Fiddler (http://www.fiddlertool.com/fiddler/) is an excellent tool for debugging Ajax applications. Once installed you can run it from the tools menu in IE and it will show you how much data is being transferred and the contents.

I have a suspicion that it could be viewstate causing the problem: for each updatepanel postback the viewstate is passed back and forth between server and client, if you have a lot of controls on there with viewstate enabled and a lot of rows it could add up to a large payload.

Anyway, give fiddler a try and see what that tells you.
pskempAuthor Commented:
Thanks NazoUK - I think you're right. I found a great article by Jeff Prosise (http://msdn.microsoft.com/en-us/magazine/cc163413.aspx) which very nicely explains why an UpdatePanel in my situation is a bad idea. Even when I try and strip out as much viewstate as possible, there's still a lot left and I can't get it nearly quick enough.

I've decided to do it all in javascript instead. Will also look into Fiddler.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now