Skip to content

C# textbox color

scampercat

Asked Jun 21, 2012, 2:12 PM EDTSolved
Share
LinkedInX
In a C# 2010 web app, I have a text box that I have disabled. I also want to make the backgound color gray. However I have not been able to find the code that will set the background color of a textbox to gray. Can you tell me how to accomplish this goal?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • ✓ Accepted answer0
    If the textbox/control is disabled, by default it will be in gray background color in chrome browser.



    For IE try the below code.

    TextBox1.BackColor = Color.LightGray;
    TextBox1.ReadOnly  = true;

    or 

    TextBox1.BackColor = Color.LightGray;
    TextBox1.Enabled= false;
    TextBox1.ForeColor = Color.Black;




    Are you disabling the control in javascript then apply the CSS for the control ?

    Look the below css class.

     
     
     
     
     
     

     


     
     
    0