Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

css - textbox

Posted on 2013-02-05
3
Medium Priority
?
521 Views
Last Modified: 2013-02-06
I don't know which section that change txtbox to gray when I set enabled = false.  How can I change font color in a specific  textbox to different color if textbox set to enabled = false?
Site.css
0
Comment
Question by:VBdotnet2005
3 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 38857783
You could try this. It should work in most modern browsers. For IE, probably only version 9 or above.

input.textEntry:disabled
{
    color:#eee
}

input.passwordEntry:disabled
{
    color:#eee
}
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 38858065
Didn't know you can address enabled and disabled properties of an input via CSS, Cool...

You could also switch CssClass or set the properties of the textbox programmatically, but CSS solution would be much cleaner.
 Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Me.TextBox1.Enabled = False Then
            Me.TextBox1.ForeColor = Drawing.Color.White
            'Me.TextBox1.CssClass = "disabled"
        Else
            Me.TextBox1.ForeColor = Drawing.Color.Black
            'Me.TextBox1.CssClass = "enabled"
        End If
 End Sub

Open in new window

Alan ";0)
0
 
LVL 3

Accepted Solution

by:
AshwaniMunshi earned 2000 total points
ID: 38858974
instead make it Readonly

<asp:TextBox ID="TextBox1" runat="server" Text = "XXXXX" ForeColor = "Red" ReadOnly = "true" ></asp:TextBox>

Then whatever color you've set in ForeColor property will apply. Or I think you can use CSS also if it is readonly and not disabled.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question