Search code examples
htmlasp.netcsscursorimagebutton

how to change the cursor of disabled ImageButton in ASP.Net


I have a dynamic generated ImageButtons in a ListView, In ItemDataBound if an image have no link i need to make it disabled, i have tried the following,

                img.Enabled = False
                img.DescriptionUrl = "javascript:void(0);"
                img.PostBackUrl = "javascript:void(0);"
                img.CssClass = "imageButtonClass"
                img.Style.Add(HtmlTextWriterStyle.Cursor, "pointer")

CSS:

.imageButtonClass
{
    cursor:pointer;
}

That's made the targeted images disabled in all browsers , however, The cursor changed to pointer in IE only. Not in Firefox and Chrome! Any suggestions?


Solution

  • Be sure you have declared a doctype. That is the source of most cross-browser inconsistency issues.

    Most new pages should be using the HTML 5 doctype as follows:

    <!DOCTYPE html>
    

    It might also help if you compare your example with this working one: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor. As you can see, this works fine in FireFox. Note the doctype declaration at the top of the page.