title: Clearing textbox on focus not working- ASP.NET
body: <p>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.</p>
  
  <p>The pageLoad method is defined as </p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
   {
          MultiViewSearchOptions.ActiveViewIndex = 0;
          txtKeywordSearch.Attributes.Add("onfocus", "this.value=string.Empty");
  
   }
  </code></pre>
  
  <p>and the textbox element is defined as </p>
  
  <pre><code>&lt;asp:TextBox ID="txtKeywordSearch" runat="server" Width="175px"&gt;Click to search...&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>I've tried several variations, whether <code>this.value=''</code>, or changing <code>onfocus</code> to <code>onclick</code>, but nothing works.  Is it due to running on the localhost, or whatnot?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I solved the problem by inserting <code>OnClick="this.value=''"</code> inside the <code>asp:TextBox</code> declaration.  Works like a charm!</p>