Search code examples
c#asp.netajaxupdatepanellinkbutton

Why my link button does a full post back although it 's triggered with an update panel


I have the following case :

a link button which triggered through AsyncPostBackTrigger .but still does a full post back !!


<asp:LinkButton ID="lbtnShowNotes" runat="server" CssClass="blue" OnClick="lbtnShowNotes_Click"> <img src="images/document_notes.png"/>notes</asp:LinkButton>

  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Panel ID="pnlNotes" runat="server" Visible="false">
                        <asp:Label ID="lbl_title" runat="server" Text="الملاحظات"></asp:Label>
                        <asp:TextBox ID="txt_Coments" runat="server" Columns="70" Rows="5" TextMode="MultiLine"></asp:TextBox>
                        <asp:LinkButton ID="lbtnOkNotes" runat="server"><img src="images/tick.png" alt=""/></asp:LinkButton>
                        <asp:LinkButton ID="lbtnCancelNotes" runat="server" CausesValidation="False" OnClick="lbtnCancelNotes_Click"><img src="images/tick.png" alt=""/></asp:LinkButton>
                    </asp:Panel>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="lbtnShowNotes" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>


Solution

  • Change the UpdatePanel's UpdateMode Property to "Conditional".

    <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server">
    

    The UpdatePanel is updated if the UpdateMode property is set to Conditional, and one of the following conditions occurs:

    • You call the Update method of the UpdatePanel control explicitly.
    • The postback is caused by a control that is defined as a trigger by using the Triggers property of the UpdatePanel control. In this scenario, the control explicitly triggers an update of the panel content. The control can be either inside or outside the UpdatePanel control that defines the trigger.
    • ...