2013-12-20 28 views
1

好吧,讓我有一個更新面板來繞過我的控件。我有2個下拉列表,它們具有從代碼隱藏和項目中繼器運行的功能。我已經在Repeater中使用不做回發的按鈕完成了測試,但linkbutton確實如此。我究竟做錯了什麼?中繼器中的LinkBut​​ton會導致回發,而按鈕不會

此外,這是在一個usercontrol沒有aspx頁面。

<asp:UpdatePanel ID="upLocation" runat="server" UpdateMode="Conditional" RenderMode="Inline"> 
<ContentTemplate> 
<asp:Repeater ID="rptMuniProducts" runat="server"> 
    <HeaderTemplate> 
     <table class="table"> 
      <thead> 
       <tr> 
        <th class="w80"></th> 
        <th>Product</th> 
        <th>Product Type</th> 
       </tr> 
      </thead> 
      <tbody> 
    </HeaderTemplate> 
    <ItemTemplate> 
        <tr> 
        <td class="actions"> 
         <asp:Button ID="btnProd" runat="server" OnClick="btnProd_Click" Text="test" /> 
         <asp:LinkButton ID="lnkDeleteProd" runat="server" OnClick="lnkDeleteProd_Click">Link Test</asp:LinkButton> 
         <asp:HiddenField ID="hdnId" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Id") %>' /> 
         </td> 
         <td><%# DataBinder.Eval(Container, "DataItem.Name") %></td> 
         <td><%# DataBinder.Eval(Container, "DataItem.Producttype") %></td> 
        </tr> 
    </ItemTemplate> 
    <FooterTemplate> 
       </tbody> 
      </table> 
    </FooterTemplate> 
</asp:Repeater> 
</ContentTemplate> 
</asp:UpdatePanel> 
+0

沒有什麼不對,並且按鈕和鏈接按鈕都回傳。如果您在Page_Load中設置斷點並查看「IsPostBack」的值,則兩個控件都是如此。您發佈的代碼正常工作正常! – afzalulh

+0

是的,他們都回發,但我不想要的頁面重新加載,並與按鈕的頁面不重新加載,並與linkbutton它does..thats問題:( – Andres

+0

你必須註冊鏈接按鈕與ScriptManager。看到這裏:http://stackoverflow.com/questions/8716362/how-to-do-asyncpostbacktrigger-for-the-linkbutton-in-the-repeater/8717079#8717079 –

回答

2

您是否嘗試過在LinkBut​​ton上設置ClientIDMode = Auto? doPostBack和非自動客戶端ID有一個長期的.NET錯誤。

相關問題