Anyname Donotcare
Anyname Donotcare

Reputation: 11393

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>

Upvotes: 1

Views: 7255

Answers (3)

Sreenu Prasad
Sreenu Prasad

Reputation: 41

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

Upvotes: 4

calorie712
calorie712

Reputation: 348

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

Upvotes: 6

Tim Schmelter
Tim Schmelter

Reputation: 460058

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

Upvotes: 2

Related Questions