Linkbutton in Repeater in AJAX Update panel

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
 
D

Dawid Rutyna

(...)
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
 
M

milop

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top