May 152012
 

Problem

I’m still fond of ASP.NET Web Forms, and I was wondering how to implement html5 placeholder for input textbox with ASP.NET 4.0 Web Forms.

Solution

To add html5 placeholder to input textbox in ASP.NET, you only need to add attribute placeholder to asp:Textbox tag. As simple as that!

<asp:TextBox ID="placeholderTextBox" runat="server"
  placeholder="html5 placeholder"></asp:TextBox>

I didn’t verify this, but I guess you will have to install “Web Standards Update for Microsoft Visual Studio 2010 SP1” first.

Input textbox with placeholder as seen in Google Chrome 18 (May 2012).

placeholder in Google chrome

When you run it Mozilla Firefox 12.

placeholder in Firefox

  • Lieffena J

    Will this work for IE ???

  • mohammad abdullah

    thank

  • RajaSekhar Alluri

    I tried but not working.. i got error as below image check it..

    • http://twitter.com/juliemetivier Julie Metivier

      Sure, you’ve got multiple id in your checkbox. You can remove ID=”placeholderTextBox” from your input

  • Rahul Pawar

    I got it. its working… thanks