禁用时更改链接按钮的颜色 [英] change color of linkbutton on disabled

查看:119
本文介绍了禁用时更改链接按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net(c#)的网页上有一个名为"linkbutton1"的链接按钮. 现在,我想在禁用链接按钮1时更改其颜色.
我想使用一个事件来执行此操作,该事件将在链接按钮的禁用过程上触发
与gridview控件中存在RowDatabound事件相同,当我们调用databind()方法时将触发该事件.
以同样的方式,当我禁用linkbutton1时,即enable = false,将触发一个事件,该事件将更改linkbutton1的颜色,

我该如何在C#

I have a linkbutton named "linkbutton1" on my webpage in asp.net(c#)
Now i want to change color of linkbutton1 when it gets disabled.
I want to do this using an event which will fire on disabled process of linkbutton
Same as there is an event of RowDatabound in gridview control, which fires when we call databind() method.
Same way when i make my linkbutton1 disabled,i.e enable=false, an event should fire which will change the color of linkbutton1,

How can i do this in C#

推荐答案

中执行此操作,就可以在执行语句linkbutton1.enable = false;时更改链接按钮的颜色. >
以下代码可以解决问题:
You can change the color of the link button, the moment you execute the statement linkbutton1.enable=false;.

The following code will do the trick:
LinkButton1.Enabled = false;
LinkButton1.ForeColor = System.Drawing.Color.Black;


希望这能回答您的问题


Hope this answers your question


感谢您的答复
但我不想在任何click事件中编写该颜色更改代码.
我有一种情况,我想在禁用linkbutton时触发一个事件
Thanx for ur reply
but i dont want to write that color change code in any click event.
I have got a situation where i want to fire an event when linkbutton gets disabled


尽管您可以在C#中通过后面的代码对其进行更新,但正确的方法实际上是使用CSS和客户端上的JavaScript.

Although you can update this in C# in the code-behind, the proper way would really be to use CSS and JavaScript on the client.


这篇关于禁用时更改链接按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆