Textboxes Different in Appearance?

Hi everyone,
I have two textboxes, textbox1 and textbox2.
Initially, textbox1 is enabled and textbox2 is disabled (Enabled="False" BackColor="#CDC9C9").
Now, in code, when I programatically set textbox2 to be enabled and the backcolor to Drawing.Color.Transparent, I am getting a different look on the textbox.
I want to make sure that the appearance of textbox2 would be the same as of textbox1.
Help. Thanks.
5/5/2009 12:59:06 AM
📁 asp.net.web-forms
📃 93655 articles.

💬 2 Replies

Hi There,
When you set BackColor to the TextBox, it actually overwrite the default TextBox style. In order to restore to original style you can set the style manually.
Set BorderColor, BorderWidth, BackColor. You can also use css style to do this by just changing the css class name.TextBox1.Enabled = true;
TextBox1.BorderWidth = new Unit(1);
TextBox1.BorderColor = System.Drawing.Color.LightGray;
TextBox1.BackColor = System.Drawing.Color.White;
Hope it helps!

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
5/5/2009 1:16:05 AM

You will need to apply same values for Enabled, BackColor and any other properties

Bind GridView to Dynamically created DataTable | Bind DataTable to DropDownList

My Blog
5/5/2009 7:03:41 AM