In this article I will explain with an example, how to create TextArea using HTML Helper in ASP.Net MVC.
Controller
There is no need to code in Controller as it is not required.
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
}
View
The View consists of a TextArea created using Html.TextArea Helper method.
The TextArea has been assigned with the name attribute.
HtmlAttributes – This array allows us to specify the additional TextArea Attributes. Here rows attribute is set to 4.
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@Html.TextArea("name" , new {@rows=4})
</body>
</html>
Screenshot
Downloads