ForeColor of disabled TextBox

Bernd

New member
Joined
Jul 1, 2003
Messages
3
Location
N
How can I set the ForeColor of a TextBox which has enabled=false?

I only get the grayed text, which is hardly seeable on a TFT-screen.
 
You cant change it!

But you can do a trick:

Code:
<asp:TextBox id="TextBox1" runat="server" ForeColor="Red" onfocus="blur();"></asp:TextBox>

Maybe this endures...
 
Thanks, this is a good trick.

Where does this onfocus-function come from, where can I read its documentation?

The problem that I still have is, that I have to disable the TextBox from server side. So in the load()-function I read from database and depending on the read data the TextBox has to be editable or readonly.
 
Hi again!

The
Code:
onfocus="blur();"
is javascript on the clientside.

For your problem code it so in your ASPX file:

Code:
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>


On serverside:

Code:
//in the PageLoad-Function
if (TextBoxMustBeDisabled == true)
{
TextBox1.Attributes.Add("onfocus", "blur();");
TextBox1.ForeColor = Color.Red;
}

Regards
 
Works, pretty good. Thanks a lot.

I used the technique with Attributes.Add already to display a MessageBox. So it is really a nice thing.
 


Write your reply...
Back
Top