Click here to Skip to main content
14,641,302 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am working with c#.
I have a text box for entering user name .

What i need is when the page load , this text box should carry the data 'username ' in ash colour and when user click on the text box the 'username' text should disappear .

when user types anything inside , the color of text should change to black from ash.

I used the below code. but color how to change?

<asp:TextBox ID="txtContact" runat="server" ForeColor="#999999"  value="Contact Number" onfocus="if (this.value == 'Contact Number')  {this.value = '';}"

                     onblur="if(this.value == '') { this.value='Contact Number';}"


1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

change your onfocus evetn to this
onfocus="if (this.value == 'Contact Number')  {this.value = '';  = '#000000';}"
Member 10112611 5-Jul-13 5:24am
Thanks a lot...I tried the same with forecolor property ..but no effect...thanks a lot again..

it is working fyn now.
Naz_Firdouse 5-Jul-13 6:07am
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100