更改禁用链接按钮的颜色
我的网格视图中有一个链接按钮,当满足特定条件时它将被禁用。我的问题是,当按钮被禁用时,按钮的颜色将变为灰色,但我不希望它变为灰色,也许是黑色。我尝试使用以下代码将灰色更改为其他颜色,但它不起作用,你们有什么想法吗?
曾尝试过:
LinkButton.ForeColor = Drawing.Color.Black
or
LinkButton.CssClass = "BlackLnkBtn"
or
LinkBUtton.Attributes("class") = "BlackLnkBtn"
I have a link button in my grid view and it will be disabled when it meets certain condition. My question is, when the button is disabled, the color of the button will change to gray and i dun wan it to be gray, perhaps black. I have tried using the following code the change gray color to others but it's not working, You guys have any idea to do do this?
Have tried on:
LinkButton.ForeColor = Drawing.Color.Black
or
LinkButton.CssClass = "BlackLnkBtn"
or
LinkBUtton.Attributes("class") = "BlackLnkBtn"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试使用下面的 CSS 和代码:
css:
代码:
Try the css and code below:
css:
Code:
我已经找到了一个解决方案,在某些情况下,我不会禁用按钮,而是将其 OnClick 属性设置为 false,并使用 CSS 样式删除文本的下划线。
这是我的代码...
i have figured out a solution, where, instead of disabling the button, i will just set it OnClick attributes to false when under certain condition and using CSS Style to remove the underline of the text.
This is my code...
<CSS>
<Code Behind>
Himadri 的解决方案是正确的。它可能对某些人不起作用的原因是您的代码可能在设置 .enabled 之前设置了 css。这里的顺序很重要,因为设置 .enabled 实际上会更改类。
Himadri's solution is the correct one. The reason why it may not work for some is that your code may have set the css before setting the .enabled. The order is important here because setting the .enabled actually changes the class.
尝试将以下 CSS 添加到
这将在将类设置为 BlackLnkBtn 后设置按钮上的
background-color:black
属性。Try adding the following CSS to
<head>
This will set the
background-color:black
property on the button after you set the class to BlackLnkBtn.尝试 LinkBUtton.Attributes.Add("class", "yourclass");
Try LinkBUtton.Attributes.Add("class", "yourclass");
你只能在FireFox中改变文本颜色,也许其他的,IE不会让步。
You can only change the text color in FireFox, maybe others, IE won't budge.