asp.net UpdatePanel not working correctly

DaKodar picture DaKodar · Oct 13, 2012 · Viewed 20.4k times · Source

Im using an UpdatePanel to refresh a datagrid with some search results but is not working and the whole page goes in postback. i hope somebody can help me, cant get this to work right. . Thanks. Here is my code:

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="left" class="pageTitle" valign="top">
                        <twc:LocalizedLiteral Text="CRMcontxt6" runat="server" />
                    </td>
                </tr>

                    <tr align="left" style="background-color: #9bbbe3">
                        <td align="left" colspan="3">
                            <asp:Label ID="lblSearch" Height="15" runat="server" Font-Bold="true" Font-Size="11"></asp:Label>
                            <asp:TextBox Width="500px" ID="Search" autoclick="BtnSearch" runat="server" CssClass="boxDesign" />
                            <asp:LinkButton  ID="BtnSearch" runat="server" CssClass="save" />
                         </td>
                    </tr>
                </table>

                   <asp:datagrid id="searchresults" runat="server">
           </ContentTemplate>

             <Triggers>
                <asp:AsyncPostBackTrigger ControlID="BtnSearch" />
            </Triggers>
            </asp:UpdatePanel>

Answer

graham mendick picture graham mendick · Oct 13, 2012

This looks like a familiar .NET Bug. Setting ClientIDMode="AutoID" on the LinkButton should fix it (by the way, you can remove the trigger. It's not needed).