I wanna have a the text "Username" in the username-Textbox in gray until the user clicks it. When he enters something the box should be empty auhtomaticly and black color again.
How to do that?
I wanna have a the text "Username" in the username-Textbox in gray until the user clicks it. When he enters something the box should be empty auhtomaticly and black color again.
How to do that?
You should check asp.net ajax watermark extender for cross browser compatibility:
First you need to include ajaxToolkit, then you can use it like this:
<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="**YouTextBoxID**"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />
modern browsers which support css3 like chrome allows a placeholder attribute to the input elements. Example:
<input name="username" placeholder="User name" />
Reference: http://www.w3schools.com/tags/att_input_placeholder.asp
Alternative is to use javascript onfocus/onblur to show/delete the placeholder text inside textbox