1

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>

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

3 Answers3

6

ClientIDMode Changes

The ClientIDMode setting in ASP.NET 4 lets you specify how ASP.NET generates the id attribute for HTML elements. In previous versions of ASP.NET, the default behavior was equivalent to the AutoID setting of ClientIDMode. However, the default setting is now Predictable.

If you use Visual Studio 2010 to upgrade your application from ASP.NET 2.0 or ASP.NET 3.5, the tool automatically adds a setting to the Web.config file that preserves the behavior of earlier versions of the .NET Framework. However, if you upgrade an application by changing the application pool in IIS to target the .NET Framework 4, ASP.NET uses the new mode by default. To disable the new client ID mode, add the following setting in the Web.config file:

<pages ClientIDMode="AutoID" />

or add ClientIDMode="AutoID" in your page directive.

http://www.asp.net/whitepapers/aspnet4/breaking-changes

LinkButton in ListView in UpdatePanel causes full postback

Community
  • 1
  • 1
calorie712
  • 348
  • 4
  • 14
  • Good find !! This fixed my issue since the application we were using started using Client id mode "Predictable" due to a version change to .NET 4.0. Thanks – Pankaj Kumar Jul 04 '16 at 11:45
4

Adding ClientIDMode="AutoID" in my page directive solved my problem.

Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67
2

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.
  • ...
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939