When I set the "Disabled" property of an ASP.NET TextBox control to false, the final rendered HTML textarea tag (sent to the browser) includes an 'class="aspNetDisabled"' attribute in addition to the 'disabled="disabled"' attribute. Where is the "aspNetDisabled" class defined?
It seems to me that it's not defined anywhere, and the real killer is that this useless class is interfering with my defined classes, because ASP.NET is rendering this into the control as a duplicate CSS class attribute:
<textarea [...] disabled="disabled" class="aspNetDisabled" class="boxsizingBorder largeinput">
Can anyone else confirm this bug?
IIS Version: 7.0.6000.16386
AppPool .NET Framework Version: v4.0
Server control tag in ASPX page:
<asp:TextBox ID="txtInput1" class="boxsizingBorder largeinput" runat="server" TextMode="MultiLine"></asp:TextBox>.
For anyone that might still be looking for this, we can define this css class during Application_Start in the Global.asax:
void Application_Start(object sender, EventArgs e)
{
WebControl.DisabledCssClass = "customDisabledClassName";
}
Source: WebControl.DisabledCssClass Property (MSDN)
I ended up doing the following, which effectively removes the insertion of the extra class for disabled items.
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
WebControl.DisabledCssClass = "";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With