<asp:UpdatePanel > doesn't work inside a table <tr>?

10,470

UpdatePanel needs to render a div or span in order to function correctly. Since neither of these elements can be rendered between table rows, UpdatePanel does not have a placeholder to render the postback response html, and thus it doesn't work.

A workaround in your case may be to see which part of your page does not need to be inside the update panel and leave it outside. You could leave just the contents of <td colspan="2"> inside the UpdatePanel.

Share:
10,470
stevekershaw
Author by

stevekershaw

Updated on October 21, 2022

Comments

  • stevekershaw
    stevekershaw over 1 year

    I have a problem getting an <asp:UpdatePanel..> to work inside a <table>.. <tr> </tr> structure and I don't know why. When the UpdatePanel is commented out everything works fine, but when I un-comment the UpdatePanel the contents of the <tr> </tr> tag doesn't even show up in Visual Studio 2010. This content does display when I run the web page but the UpdatePanel doesn't work. Non of my other web pages in this project have this problem but, then again, I use <div>s instead of <table>s in them. One other thing. The is in my MasterPage. Here is my script:

    <asp:UpdatePanel ID="W9UpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <tr>
              <td colspan="6">
                <div class="branchSetupSectionTitle">W-9 Information:</div>
              </td>
            </tr> 
            <tr>
               <td colspan="2">
                 <asp:Button ID="btnDownloadW9Pdf" runat="server" 
                 Text="Download W-9"  onclick="btnDownloadW9Pdf_Click" AutoPostBack="True" /> 
                 <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator24" 
                  runat="server" ControlToValidate="txtFirstPaymentAmount" Display="Dynamic" 
                  ErrorMessage="The dollar amount you entered is in the wrong format." 
                  ForeColor="Red" ValidationExpression="^\d+(\.\d\d)?$">*</asp:RegularExpressionValidator>--%>
                  <asp:CheckBox ID="chkW9FormSubmitted" runat="server" AutoPostBack="True" 
                  oncheckedchanged="chkW9FormSubmitted_CheckedChanged" 
                  Text=" I have submitted this W-9 Form" />
                </td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
             </tr> 
        </ContentTemplate>
    </asp:UpdatePanel>
    
       </tr>
    

    The event fires for both the button and the checkbox but the entire page is refreshed. Thanks for your help.

  • luk2302
    luk2302 about 9 years
    explain what you changed.
  • Valdez V.
    Valdez V. almost 6 years
    Either put your whole table inside the UpdatePanel, or set your UpdatePanel in a table cell. Also pay attention to what is being rendered inside the UpdatePanel - I had a ASP NET PlaceHolder that had some unclosed html tags that provoked nasty, unexpected results.