Problems with LinkButton generated from code behind RRS feed

  • Question

  • User1287136399 posted


    I have a problem with LinkButtons that I am generating from code behind.

    LinkButton lbt = new LinkButton();
    lbt.Text = "<table><tr><td style=\"width:268px;\"><h4 style=\"color:Black;margin;\">" + DbHandler.getInstance().getUserName(m.from) +
    "</h4><h5 style=\"margin:0;color: Gray\">" + date +
    "</h5></td><td><h3 style=\"margin:0;color: Black;\">" + m.subject + "</h3></td></tr></table>";
    lbt.CommandArgument = m.id + "|Send|Rediger";
    lbt.Command += new CommandEventHandler(lbtMessage_Command);

    1. problem

    In IE8 it will not fire, in everything else IE9, IE10, Chrome and Firefox there is no problem.

    2. problem

    There is genereted more the one, and first time you click on it nothing hapens, but then you can click on nomatter witch one and the popup comes, and if you closes the popup and click on an other it comes first time.

    Is there any one ho have any suggestions for thes to problems.

    Wednesday, August 21, 2013 4:46 PM


  • User-183374066 posted

    lbt.CommandArgument = m.id + "|Send|Rediger";

    Dont put special characters spaces in ID .. Remove pipe | from ID. Also your ID should start from Character not digit.. Change it to

    lbt.CommandArgument = "SendRediger" + Convert.ToString(m.id);

    lbt.Command += new CommandEventHandler(lbtMessage_Command);

    Make sure you define CommandEventHandler 

    protected void lbtMessage_Command(object sender, CommandEventArgs e)
       //You command handler

    and you have to recreate on page_load on postbacks


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 21, 2013 5:06 PM