2

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>
Andres
  • 2,013
  • 6
  • 42
  • 67
  • There's nothing wrong and both the button and link buttons are posting back. If you set a breakpoint in Page_Load and see the value of `IsPostBack`, it is true for both controls. Your posted code is working fine as expected! – afzalulh Dec 20 '13 at 21:14
  • yes they both post back, but what i don't want is for the page to reload, and with the button the page doesn't reload and with linkbutton it does..thats the problem :( – Andres Dec 20 '13 at 21:25
  • You have to register the link button with ScriptManager. See here: http://stackoverflow.com/questions/8716362/how-to-do-asyncpostbacktrigger-for-the-linkbutton-in-the-repeater/8717079#8717079 – Eugene S. Dec 20 '13 at 22:27
  • @EugeneS. I saw that but how do I get the scriptmanager from within the usercontrol? – Andres Dec 20 '13 at 22:29
  • You can try this: http://stackoverflow.com/questions/8601525/how-to-get-the-scriptmanager-placed-on-master-page-into-child-pages-code-behind – Eugene S. Dec 20 '13 at 22:35

1 Answers1

2

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

graham mendick
  • 1,839
  • 1
  • 17
  • 15