Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear all,

When I set my textbox.Enabled = false; it lose all style from css.

But I can set textbox.Readonly = true, and style from css works well.

How can I set style from css for disabled textbox?

Thanks very much.
Posted
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 23:52pm    
The short answer is: you screw up something. What? Hard to say without looking at your code. Create some code sample complete with CSS and HTML. You would need just few lines of code to show it. Please use "Improve question".
--SA

Thanks all, I found the solution to do it.
There are no CSS style apply when I set Enabled=false.
But when I set disabled=true, it works well.
Exampe
<textbox txttest="" class="test" disabled="true"></textbox>
 
Share this answer
 
Thanks very much,

It works well for txtClass:readonly.
But it doesn't work for txtClass:disabled.
I tried txtClass[disabled] but it doesn't work too.
 
Share this answer
 
Hi,

You need to specify the styles for disabled text box explicitly as follows:

Suppose the css class of your textbox is txtClass and it has background color : yellow.

Then these will be the classes you need to put in style sheet:


CSS
.txtClass 
{
 background-color:yellow;
}

.txtClass :disabled
{
 background-color:yellow;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900