How to define MaxLength property for a textbox in ASP.NET MVC Razor View?

Below is a sample code snippet which demonstrates how to define MaxLength property for a textbox in ASP.NET MVC Razor View.

@{

if (@ViewContext.ViewData.ModelState.IsValid)

{

ViewBag.Title = "Index";

}

}

<h2>Abundant Code</h2>

@Html.TextBoxFor (model => model.FirstName, new { maxlength = "100" });