Gets a value that indicates whether the control should set the disabled attribute of the rendered HTML element to "disabled" when the control's IsEnabled property is false.
Assembly: System.Web (in System.Web.dll)
In derived classes, this property indicates how ASP.NET should render HTML for a control when the control is disabled.
When the Enabled property of an ASP.NET control is set to false (that is, when the control is disabled), the intent is that ASP.NET should render the control in the page, but display it in a disabled state (typically dimmed). If a parent control is disabled, children of that control are also displayed as disabled. In that case, the child control's IsEnabled property is set to false, even though its Enabled property might be set to true.
In ASP.NET 3.5 and earlier versions, when a control's IsEnabled property is false, ASP.NET sets the disabled attribute to "disabled" in the HTML element that it renders for the control. However, the HTML 4.01 standard allows the disabled attribute only on certain elements that are used for user input. For example, the disabled attribute is allowed for input elements, but not for span elements.
Most browsers support a default disabled appearance for display-only elements that have disabled attributes. However, in order to comply with HTML standards, by default ASP.NET 4 omits invalid attributes.
If theproperty is true, ASP.NET renders a disabled attribute when the control is disabled. If this property is false, ASP.NET renders a class attribute when the control is disabled.
Derived classes override this property to return false if all the following conditions are true:
The control renders an HTML element that does not support the disabled attribute.
The RenderingCompatibility property indicates an ASP.NET version number lower than 4.0.
The RenderingCompatibility property indicates an ASP.NET version number lower than 4.0, the value of the control's property might return true even if the rendered HTML does not support the disabled attribute.property does not necessarily indicate whether the HTML element that is rendered for a control supports (allows) the disabled attribute. If a control's
When you use Visual Studio to upgrade a Web project to ASP.NET 4 from an earlier version, Visual Studio automatically sets the controlRenderingCompatibilityVersion attribute in the Web.config file (which sets the RenderingCompatibility property) to the earlier version number. Because the property always returns true when the RenderingCompatibility property is lower than 4.0, this causes Web controls to render HTML for disabled controls as they did in the earlier version. If you want an upgraded Web site to render HTML using the algorithm introduced in ASP.NET 4, you can change or remove the controlRenderingCompatibilityVersion attribute. For more information, see the RenderingCompatibility property.
To provide a disabled appearance for disabled controls, you must define a CSS rule for the class that is represented by the value of the WebControl.DisabledCssClass property.
The HTML element that is rendered for a control might have more than one value in its class attribute if there is a value in its CssClass property. For more information, see the DisabledCssClass property.
The following example shows markup for a disabled Label control:
<asp:Label id="Label1" runat="server" Text="Test" Enabled="false"/>
In ASP.NET 3.5 and earlier versions, this markup renders the following HTML:
<span id="Label1" disabled="disabled">Test</span>
<span id="Label1" class="aspNetDisabled">Test</span>
Available since 4.0