Input box - Disabled - Change Appearance / Make Text Black

by rlynch February 01, 2010 12:49

A situation came up last week where I had a number of asp:textbox controls (which render as standard  HMTL Input Controls type=text). I wanted to load information into textbox's based on a selection from a combo/dropdown list box, but didn't wish the user to be able to modify the content.

The problem was when an input control has it's enabled property set to true, the text is grey and it just doesn't match the rest of the form. It also wasn't appropriate to use a div or span or lable - or at least it didn't seem to be correct.

The key is that the input control has a readonly property. So if you don't wish a user to modify the content, but you also don't want the control to look different, you can simply set the readonly property to readonly.

e.g. <input name='somename' id='samename' readonly='readonly' value='some value'> 

The other interesting side effect to this is that you can now change the color of the text.. if you want it to be blue, it can be blue (and not grey)

 

Hope that helps.

Rob

 

 

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

asp.net | CSS | HTML

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar