Tag Archives: anchor tag

CSS for Disabled anchor tag on asp.net

In the asp.net when the link was disabled it used to apply the disabled properties for the anchor tags. With the 4.0 .Net framework, the colors won’t apply automatically. They introduced a new property for all controls DisabledCssClass which is a string property to set/get the disabled css class. This property is applied to all the controls.
This property can be used to change the name that is rendered for the DisabledCssClass property of individual Web controls. By default, this property returns “aspNetDisabled“.
When SupportsDisabledAttribute is overridden in a derived class to return false, the value of the DisabledCssClass property is rendered as the value of the class attribute of the HTML element for the control. In that case, if there is a value in the CssClass property, both CSS classes will be applied to the rendered HTML element. The class attribute will consist of the value of the DisabledCssClass property followed by the value of the CssClass property, separated by a space.
This property is static, which means that you can set it only for the WebControl class. Whatever value you set it to is used for all controls in a Web application. You cannot specify different values for individual controls.
If you want to set a new class for all the controls all over the application, you can set a new class in the application_start event in global.asax

void Application_Start(object sender, EventArgs e)
webcontrol.DisabledCssClass = somecssclass;

If you want to set the DisabledCssClass for an anchor tag, you can do that in the stylesheet like


This set of property is applied to anchor tag without affecting any other controls.