Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the "aspNetDisabled" class defined and why does ASP.NET render an interfering duplicate CSS "class" attribute for it?

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?


Additional Info

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>.
like image 510
Triynko Avatar asked Apr 04 '11 19:04

Triynko


2 Answers

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)

like image 185
Timo Avatar answered Sep 21 '22 10:09

Timo


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 = "";
}
like image 39
Austin Salgat Avatar answered Sep 21 '22 10:09

Austin Salgat