MVC Helper TextArea - Placeholder Not Displaying

I have the following code in my .cshtml:

@Html.TextArea("txtComments", new { style = "width: 450px;", placeholder = "Enter Comments here" }) 

But the placeholder is not displayed at all. Did I miss something?

A source:

 <textarea cols="20" id="txtComments" name="txtComments" placeholder="Enter Comments here" rows="2" style="width: 450px;"> </textarea> 
+6
source share
1 answer

Put @ in front of the style and in bulk, for example, even put htmlAttributes: in front of it.

 @Html.TextArea("txtComments", htmlAttributes: new { @style = "width: 450px;", @placeholder = "Enter Comments here" }) 

And this is the exact result that I get:

 <textarea cols="20" id="txtComments" name="txtComments" placeholder="Enter Comments here" rows="2" style="width: 450px;"></textarea> 

If this shows the placeholder, but it still does not appear, make sure you are using a modern web browser, you can find a list of supported browsers here: http://caniuse.com/input-placeholder

 < IE10 does not support it. 

If you need support in these browsers, perhaps this solution will help you: http://webdesignerwall.com/tutorials/cross-browser-html5-placeholder-text

+8
source

All Articles