Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

ajax

asp.net

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.

like image 777
stevekershaw Avatar asked Feb 22 '13 22:02

stevekershaw


People also ask

How does UpdatePanel work in asp net?

UpdatePanel controls are a central part of AJAX functionality in ASP.NET. They are used with the ScriptManager control to enable partial-page rendering. Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated.

Can we use nested UpdatePanel in Ajax?

To nest UpdatePanel controlsIn the AJAX Extensions tab of the toolbox, double-click the ScriptManager control to add it to the page. In the toolbox, double-click the UpdatePanel control to add an UpdatePanel control to the page.

What is UpdateMode in UpdatePanel?

If the UpdateMode property is set to Always, the UpdatePanel control's content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls inside other UpdatePanel controls and postbacks from controls that are not inside UpdatePanel controls.

What is postback trigger in UpdatePanel?

AsyncPostBackTrigger - use these triggers to specify a control within or outside of the UpdatePanel that, when clicked, should trigger a partial page postback. PostBackTrigger - use these triggers to have a control within the UpdatePanel cause a full page postback rather than a partial page postback.


1 Answers

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.

like image 63
sath Avatar answered Sep 30 '22 19:09

sath