Linkbutton in Repeater in AJAX Update panel

  • Thread starter Thread starter milop
  • Start date Start date
M

milop

Hello.

Using ASP.Net 2.0 and an AJAX Enabled web application, I have a Repeater
control on a page with two ImageButton columns and a LinkButton column.

I have an UpdatePanel on the page with UpdateMode set to Conditional. The
trigger is the Repeater control.

Clicking either of the ImageButtons works as expected. When I click the
LinkButton the first time, it works as expected. Clicking it again results
in the browser displaying the "Stop running this script ..." message.

I'm not doing anything special with the LinkButton properties or
code-behind, so I don't know what the heck is going on.

I resorted to removing the LinkButton and using an asp:Button with a style
that makes it look like a link.

Any ideas anyone?

Thanks in advance,

Mike
 
(...)
Clicking either of the ImageButtons works as expected. When I click the
LinkButton the first time, it works as expected. Clicking it again results
in the browser displaying the "Stop running this script ..." message.
(...)

I had no such problem using Framework 3.5. My code:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<Person> persons = new List<Person>();
persons.Add(new Person("AName", "ASurname", "ANick"));
persons.Add(new Person("BName", "BSurname", "BNick"));
persons.Add(new Person("CName", "CSurname", "CNick"));
Repeater1.DataSource = persons;
Repeater1.DataBind();
}
}

protected void UpdatePanel1_Load(object sender, EventArgs e)
{
Label1.Text = string.Concat("Time: ",
DateTime.Now.ToLongTimeString());
}
}



<%@ Page Language="C#" EnableEventValidation="true" AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Scriptmanager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional" OnLoad="UpdatePanel1_Load">
<Triggers>
<asp:PostBackTrigger ControlID="Repeater1" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Button ID="Button1" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "Name")%>' />
<asp:Button ID="Button2" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "Surname")%>' />
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%#
"[" + DataBinder.Eval(Container.DataItem, "Nick") + "]" %>' />
<br />
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>


Dawid Rutyna
 
Perhaps 3.5 corrected something.

I'll give it a shot with VS 2008.

Thank Dawid.

Dawid Rutyna said:
(...)
Clicking either of the ImageButtons works as expected. When I click the
LinkButton the first time, it works as expected. Clicking it again
results in the browser displaying the "Stop running this script ..."
message.
(...)

I had no such problem using Framework 3.5. My code:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<Person> persons = new List<Person>();
persons.Add(new Person("AName", "ASurname", "ANick"));
persons.Add(new Person("BName", "BSurname", "BNick"));
persons.Add(new Person("CName", "CSurname", "CNick"));
Repeater1.DataSource = persons;
Repeater1.DataBind();
}
}

protected void UpdatePanel1_Load(object sender, EventArgs e)
{
Label1.Text = string.Concat("Time: ",
DateTime.Now.ToLongTimeString());
}
}



<%@ Page Language="C#" EnableEventValidation="true" AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Scriptmanager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional" OnLoad="UpdatePanel1_Load">
<Triggers>
<asp:PostBackTrigger ControlID="Repeater1" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Button ID="Button1" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "Name")%>' />
<asp:Button ID="Button2" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "Surname")%>' />
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%#
"[" + DataBinder.Eval(Container.DataItem, "Nick") + "]" %>' />
<br />
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>


Dawid Rutyna
 
Back
Top