asp.netinternet-explorergoogle-chromeonclickasplinkbutton

LinkButton's OnClick does not fire in IE8


The following works just fine in Chrome.

<asp:LinkButton runat="server" ID="lbEdit" OnClick="lbEdit_Click">
    <button type="button" class="edit">
         Edit
    </button>
</asp:LinkButton>

And here is the CSS for button and its subclass.

button
{    
    padding: 3px;
}
button.edit 
{
    background:#3f6096;
    border:none;
    font:10px verdana;
    color:#fff;
    width:71px;
    margin-top:3px;
}

As you can see, nothing special; just colors and beautiful things.
I click on the blue Edit button and it fires the OnClick postback just fine.... in Chrome!
But if I do the same in IE8, it just does nothing; doesn't even detect a click.

To help pinpoint the problem, I removed the tag and kept just the word "Edit", and it works just fine in IE8 as a simple underlined link; the postback fires.

So, Why can't IE8 accept anything within LinkButton?


Solution

  • Why use a LinkButton if you need to handle a postback and look like a button at the same time? Why not make it just a Button? It seems to me that the only reason to use one over the other is appearance. Functionally, they're both supposed to trigger a postback.