Redigeeri

Jagamisviis:


WebControl.DisabledCssClass Property

Definition

Gets or sets the CSS class to apply to the rendered HTML element when the control is disabled.

public:
 static property System::String ^ DisabledCssClass { System::String ^ get(); void set(System::String ^ value); };
public static string DisabledCssClass { get; set; }
static member DisabledCssClass : string with get, set
Public Shared Property DisabledCssClass As String

Property Value

The CSS class that should be applied to the rendered HTML element when the control is disabled. The default value is "aspNetDisabled".

Examples

The following example shows rendered HTML for a disabled Label control when the SupportsDisabledAttribute property is false, when the DisabledCssClass property has its default value, and when the CssClass property is empty.

<span id="Label1" class="aspNetDisabled">Test</span>

The following example shows rendered HTML under the same conditions except that the CssClass property has the value "SampleStyle":

<span id="Label1" class="aspNetDisabled SampleStyle">Test</span>

For more information, see the SupportsDisabledAttribute property.

Remarks

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 use a class name different from the default value of "aspNetDisabled", you typically put the code to do that in the Application_Start method of the Global.asax file, as shown in the following example:

Private Sub Application_Start(
    ByVal sender As Object, ByVal e As EventArgs)
    WebControl.DisabledCssClass = "customDisabledClassName"
End Sub
void Application_Start(object sender, EventArgs e)
{
    WebControl.DisabledCssClass = "customDisabledClassName";
}

Applies to

See also