I am using <asp:TextBox&开发者_Go百科gt;
not HTML textbox and I want to display hint text.
Is there any way to achieve that?
I have tried for making static text and color it gray but not getting how to make it empty when cursor get focus to that textbox.
<asp:TextBox ID="TextBox1" runat="server" placeholder="Hint Text"></asp:TextBox>
Use a ASP.NET WaterMark TextBox
It is in Ajax Toolkit
You, can give in Code behind like follows
textBox.Attributes.Add(“onfocus”, “clearText(this,’” + defaultText + “‘)”);
And also refer to this to know more.
You can using "placeholder" properties for textbox.
Example
<asp:TextBox ID="TextBox1" runat="server" Width="233px" placeholder="Search"></asp:TextBox>
You could use the HTML5 placeholder attribute for that. The downside is that it's only supported by some browsers. Fortunately you have JQuery Placeholder to the rescue. This plugin makes the placeholder behavior available for unsupported browsers.
Check it out here JQuery Placeholder
text input watermarks using javascript. refer this it might help u http://naspinski.net/post/Text-Input-Watermarks-using-Javascript-%28IE-Compatible%29.aspx
just add property placeholder="HintText"
in your asp textbox
精彩评论