Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 27-Sep-12 17:50pm
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 

.txtClass 
{
 background-color:yellow;
}
 
.txtClass :disabled
{
 background-color:yellow;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 598
1 George Jonsson 268
2 OriginalGriff 215
3 CPallini 210
4 PIEBALDconsult 155
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,263
2 CPallini 4,750
3 George Jonsson 3,227
4 Gihan Liyanage 2,487


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100