Linkbutton in Repeater in AJAX Update panel

Discussion in 'ASP .Net' started by milop, Mar 21, 2009.

  1. milop

    milop Guest

    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
     
    milop, Mar 21, 2009
    #1
    1. Advertising

  2. milop

    Dawid Rutyna Guest

    (...)
    > 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
     
    Dawid Rutyna, Mar 23, 2009
    #2
    1. Advertising

  3. milop

    milop Guest

    Perhaps 3.5 corrected something.

    I'll give it a shot with VS 2008.

    Thank Dawid.

    "Dawid Rutyna" <> wrote in message
    news:gq7404$e20$...
    > (...)
    >> 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
    >
     
    milop, Mar 24, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sathyaish
    Replies:
    3
    Views:
    3,113
    Sathyaish
    Sep 8, 2005
  2. Henrique
    Replies:
    1
    Views:
    2,872
    Henrique
    Sep 12, 2006
  3. =?Utf-8?B?cm9kY2hhcg==?=

    datalist and ajax update panel

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 2, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    734
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 2, 2006
  4. =?Utf-8?B?cm9kY2hhcg==?=

    ajax update panel trigger

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    535
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 7, 2006
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    189
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page