Sunday, March 6, 2011

ASP.NET AJAX No update of screen on partial postback

We have an issue on our page whereby the first time a button posts back (we have ASP.NET ajax to enable partial updates) nothing happens, then on every subsequent click, the information is updated as if the previous event fired.

Here's the code for the page. The events are button clicks fired from within the table. Which is rerendered at the backend.

<asp:ScriptManager EnablePartialRendering="true" ID="scrptMgr1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server" ID="folderContainer">
        <ContentTemplate>
            <asp:Table id="FolderTable" CssClass="FolderTable" runat="server" CellSpacing="0"></asp:Table>
        </ContentTemplate>
    </asp:UpdatePanel>

Any ideas?

Thanks.

From stackoverflow
  • Did you try an HTML table, with or without runat="server" ?

    Do you add or remove controls inside the table in the postback?

    Rob Stevenson-Leggett : Yes we completely rebuild the table within the postback
  • Your table is probably being populated too late in the page lifecycle. Try creating the table in PreInit.

    Rob Stevenson-Leggett : I've tried moving it to PreInit and the code goes through fine but now I get a blank page... odd.
    devio : why is this then the accepted answer?
  • Inspired by Robert's answer:

    In which event handler do you build your table? If you build it in Page_Load without checking IsPostBack), then the button's click event has not been handled yet.

    You need to build the table in the button click handler.

0 comments:

Post a Comment