Here on SO, when you click on the search text box, the default text disappears. I’m trying to implement similar functionality on a site. Unfortunately, I can’t get it to work in either FF or Chrome running on the localhost server.
The pageLoad method is defined as
protected void Page_Load(object sender, EventArgs e)
{
MultiViewSearchOptions.ActiveViewIndex = 0;
txtKeywordSearch.Attributes.Add("onfocus", "this.value=string.Empty");
}
and the textbox element is defined as
<asp:TextBox ID="txtKeywordSearch" runat="server" Width="175px">Click to search...</asp:TextBox>
I’ve tried several variations, whether this.value='', or changing onfocus to onclick, but nothing works. Is it due to running on the localhost, or whatnot?
EDIT
I solved the problem by inserting OnClick="this.value=''" inside the asp:TextBox declaration. Works like a charm!
You could use one of the jQuery watermark plug-ins (e.g. this one) or the Ajax Control Toolkit’s watermark extender.