Question

How to get the layout similar to the image below used by stackoverflow using mvc4/razor views. The watermark dissppears only after a text is entered. Not while focussing on the textboxenter image description here

Was it helpful?

Solution

Placeholders are a client-side feature, and has nothing to do with the server-side platform you're using.

In HTML5, you can use the placeholder="" attribute, like so:

<input type="text" placeholder="First name" />

In ASP.NET MVC, you can add the attribute like so:

Html.InputFor( m => m.FirstName, new { placeholder="First name" } )

IE8 does not support placeholders, but you can emulate them with a number of jQuery and Mootools add-ons that replicate the functionality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top