Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working with asp.net 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?

XML
<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';}"
                        Width="251px"></asp:TextBox>
Posted

1 solution

change your onfocus evetn to this
HTML
onfocus="if (this.value == 'Contact Number')  {this.value = ''; this.style.color  = '#000000';}"
 
Share this answer
 
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900