【问题标题】:how to change the cursor of disabled ImageButton in ASP.Net如何在 ASP.Net 中更改禁用 ImageButton 的光标
【发布时间】:2013-11-04 13:57:25
【问题描述】:

我在 ListView 中有一个动态生成的 ImageButtons,在 ItemDataBound 中,如果图像没有链接,我需要将其禁用,我尝试了以下方法,

                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;
}

这使得目标图像在所有浏览器中都被禁用,但是,光标仅在 IE 中变为指针。不在 Firefox 和 Chrome 中! 有什么建议吗?

【问题讨论】:

  • 图像按钮默认应该有 cursor:pointer。您可以在 jsfiddle.net 上为按钮发布一些呈现的 HTML 以显示问题吗?

标签: html asp.net css cursor imagebutton


【解决方案1】:

确保您已经声明了一个文档类型。这是大多数跨浏览器不一致问题的根源。

大多数新页面应使用 HTML 5 文档类型,如下所示:

<!DOCTYPE html>

如果您将您的示例与以下工作示例进行比较,这也可能会有所帮助:https://developer.mozilla.org/en-US/docs/Web/CSS/cursor。如您所见,这在 FireFox 中运行良好。请注意页面顶部的 doctype 声明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    相关资源
    最近更新 更多