简体   繁体   中英

LinkButton in Repeater causes postback and button doesn't

Ok so I have an update panel sorrounding my controls. I have 2 dropdownlists which have functions they run from codebehind and a repeater of items. I've done the test in a Repeater using a button it doesn't do a postback, but the linkbutton does. What am I doing wrong?

also this is inside a usercontrol no aspx page.

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

Have you tried setting ClientIDMode=Auto on the LinkButton? There's a long-standing .NET bug with doPostBack and non-auto client ids.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM