Link to home
Start Free TrialLog in
Avatar of pskemp
pskempFlag for Afghanistan

asked on

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:TableCell>
        <asp:UpdatePanel ID="upd1" runat="server" UpdateMode="Conditional">
        <Triggers>
        <asp:AsyncPostbackTrigger ControlID="imgBespoke" EventName="Click" />
        </Triggers>
            <ContentTemplate>
            <asp:Table ID="rtbDetails" runat="server" CssClass="subtable"></asp:Table>
            </ContentTemplate>
        </asp:UpdatePanel>
 </asp:TableCell>

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
ASKER CERTIFIED SOLUTION
Avatar of NazoUK
NazoUK
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pskemp

ASKER

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.