Wednesday, March 28, 2012

UpdatePanel - Repeater - Hyperlink

We have what seems like a simple problem...We have a report that we have created within an updatepanel. The repeater in that UPanel has hyperlinks that will allow us to "drill down" to specific information. When we click that Hyperlink, we want to trigger another updatepanel to display details in it. To summarize what we want to do:

1) UPANEL1 will have a repeater which will have hyperlinks

2) Clicking a hyperlink in UPANEL1 will invoke a trigger in UPANEL2

3) UPANEL2 will then update itself with the details of the record we clicked on in UPANEL1

Does this make sense?

I'm having the exact same problem. I'm using LinkButtons, not Hyperlinks (which I assume you're using too, since Hyperlinks don't postback) but other than that, exactly the same problem. The things always post back, and I don't want them to. Did you, or anyone else for that matter, ever find a solution?

Do you guys have some code to share? I think it should be as simple as adding the repeater as an AsyncPostBack trigger to UpdatePanel2... is that what you tried?


I have exactly the same problem and if I just replace my LinkButtons by Buttons, everything works.


I got itSmile. At least I known how to work arround it.

The problem comes from LinkButton without an ID attribute.

The following page shows how to reproduce the problem :

<%@. Page Language="C#" EnableViewState="false" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXEnabledWebApplication1._Default" %><html xmlns="http://www.w3.org/1999/xhtml" ><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Repeater DataSource="<%# Data%>" runat="server"> <ItemTemplate> OK <asp:Button runat="server" Text="<%# Container.DataItem%>" /> OK <asp:LinkButton ID="LinkButton1" runat="server" Text="<%# Container.DataItem%>" /> NOK <asp:LinkButton runat="server" Text="<%# Container.DataItem%>" /> <br /> </ItemTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>
using System;using System.Web.UI;namespace AJAXEnabledWebApplication1{public partialclass _Default : Page {public string[] Data =new string[] {"aaaaa","bbbb","cccc","dddd"};protected void Page_Init(object sender, EventArgs e) { DataBind(); } }}

In the page, we have a Repeater with one Button and 2 LinkButton inside an UpdatePanel.

When the button or the first link are clicked, no problem. Only the panel is updated.

When the second link is clicked, the page completly reloads.

I don't know why, but adding the ID to the LinkButton solves the problem.

No comments:

Post a Comment