0

I am trying to set place holder to textbox or multi line text box in MVC 4. So far it is not working.

[Display(Name = "Location", Prompt = "Enter info related to Location")]
public string LocationDesc { get; set; }

And the View as below

@Html.EditorFor(model => model.LocationDesc , new { placeholder = "Enter info related to Location" })

Place holder just need to show some information and I am happy to display it anywhere (View or model)

We are using MVC4.

Cheers

user2739418
  • 1,623
  • 5
  • 29
  • 51

1 Answers1

1

You cannot use Placeholder attribute on @Html.EditorFor() in asp.net mvc,there are two solutions for your problem :

1.) You can make a custom attribute for @Html.EditorFor() a great article on this is there on stackoverflow link :- Html5 Placeholders with .NET MVC 3 Razor EditorFor extension? and you can visit this link also http://aspadvice.com/blogs/kiran/archive/2009/11/29/Adding-html-attributes-support-for-Templates-2D00-ASP.Net-MVC-2.0-Beta_2D00_1.aspx

2.) Instead of @Html.EditorFor() you can use @Html.TextAreaFor()

Community
  • 1
  • 1
Kartikeya Khosla
  • 18,743
  • 8
  • 43
  • 69