Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabled aspx button lose bootstrap class

I have this textbox

<asp:TextBox ID="tbid" runat="server" class="form-control"></asp:TextBox>

form-control is a bootstrap class so the textbox gets the bootstrap look, if I disable the control from code using

tbid.Enabled = false;

the textbox loses the form-control class, after inspected the textbox I found out that it gets replaced by the aspNetDisabled class.

how I can prevent the change of class I want to keep the disabled button with the bootstrap look even if it is disabled.

like image 206
YHAM Avatar asked Feb 01 '17 22:02

YHAM


2 Answers

You can do this:

// Code
tbid.Attributes["disabled"] = "disabled";
like image 128
Farzin Kanzi Avatar answered Sep 20 '22 05:09

Farzin Kanzi


I was having similar issues, but strangely only on some buttons on my page, so this piqued my curiosity...

Try using the CssClass instead of Class attribute, and it will work as expected.

<asp:Button id="Button1" runat="server" CssClass="btn btn-warning" Text="My Button" OnClick="Button1_Click" />
like image 45
AaronC Avatar answered Sep 24 '22 05:09

AaronC