2013-02-22 35 views
4

我有一個問題,​​在<table>.. <tr> </tr>結構中工作,我不知道爲什麼。當UpdatePanel中被註釋掉一切正常,但是當我取消註釋的UpdatePanel的<tr> </tr>標籤的內容甚至沒有在Visual Studio 2010中顯示出來,當我運行網頁此內容不顯示,但在UpdatePanel沒有按」工作。在這個項目中,我的其他網頁沒有這個問題,但是,我再次使用<div>而不是<table> s。另一件事是 。 在我的母版頁。 這裏是我的腳本: <asp:UpdatePanel>不能在表格內工作<tr>?

<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> 

的事件觸發兩個按鈕,複選框,但整個頁面被刷新。 感謝您的幫助。

+0

steveekershaw你有沒有嘗試格式化你的項目中的代碼..?什麼是代碼看起來像上面最後看起來你有打算在那裏不能告訴,除非你展示完整的ASPX代碼也有一些格式問題,爲什麼你有這種類型的代碼在你的母版頁..?不應該將代碼放在從MasterPage繼承的Aspx頁面之一中。? – MethodMan 2013-02-22 22:43:07

+0

[應的問題包括標籤的標題?](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles#_=_) - 不,他們不應該。 – Brian 2013-02-22 22:51:21

+0

@布賴恩在這種情況下,它的確定有它,看到這一行'我可以使用jQuery到foo欄上的巴茲,還是我用普通的JavaScript卡住?'。除了他提到的所有內容都被標記在他的問題中。 – AbZy 2013-02-22 22:57:13

回答

4

UpdatePanel需要呈現一個div或跨度才能正常運行。由於這兩個元素都不能在表格行之間進行渲染,因此UpdatePanel沒有佔位符來呈現回發響應html,因此它不起作用。

在你的情況下一種解決方法可能是看到了您的網頁的一部分,並不需要是更新面板內部和外部離開。您可以在UpdatePanel中保留<td colspan="2">的內容。

-1
<asp:ScriptManager ID="scm" runat="server"> 
</asp:ScriptManager> 
<fieldset> 
<legend>Truck Master Entry Form</legend> 
<asp:UpdatePanel ID="upd1" runat="server"> 
<ContentTemplate> 
<table cellpadding="2" cellspacing="1"> 
<tr> 
        <td align="right"> 
         Truck no : 
        </td> 
        <td align="left"> 
         <asp:TextBox ID="truckno" runat="server" Width="120px" Height="20px" /> 
        </td> 
       </tr> 
       <tr> 
        <td align="right"> 
         Size : 
        </td> 
        <td align="left"> 
         <asp:DropDownList ID="drptrucksize" runat="server" Width="120px" Height="20px" DataValueField="WEIGHT" 
          DataTextField="SIZE" OnSelectedIndexChanged="drptrucksize_SelectedIndexChanged" 
          AutoPostBack="true" /> 
        </td> 
       </tr> 
       <tr> 
        <td align="right"> 
         Type : 
        </td> 
        <td align="left"> 
         <asp:TextBox ID="txttrucktype" runat="server" Width="120px" Height="20px" /> 
        </td> 
       </tr> 
       <tr> 
        <td align="right"> 
         Weight : 
        </td> 
        <td align="left"> 
         <asp:TextBox ID="txtweight" runat="server" Width="120px" Height="20px" /> 
        </td> 
       </tr> 
       <tr> 
        <td align="right"> 
         &nbsp; 
        </td> 
        <td align="left"> 
         <asp:Button ID="btnsave" runat="server" Text="Save" Width="100px" Height="50px" /> 
         <asp:Button ID="btncancel" runat="server" Text="Cancel" Width="100px" Height="50px" /> 
        </td> 
       </tr> 
      </table> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
+0

解釋你改變了什麼。 – luk2302 2015-04-05 12:30:43

0

更新面板需要放在表格之外。看看

穆罕默德Shahnawaz的代碼。