Multiline TextBox or TextArea with
@Html.EditorFor can be achieved in ASP.NET MVC by decorating your field by [DataType] attribute in your view model as given belowpublic class MyViewModel
{
[DataType(DataType.MultilineText)]
public string Text { get; set; }
}
Then, pass the ViewModel to your viewpublic class HomeController : Controller
{
public ActionResult Index()
{
return View(new MyViewModel());
}
}
The below view with @Html.EditorFor will render a Multiline TextBox or TextArea in ASP.NET MVC Razor view@model AppName.Models.MyViewModel
@using (Html.BeginForm())
{
@Html.EditorFor(x => x.Text)
<input type="submit" value="OK" />
}