title: ASP.NET MVC 3 - Data Annoation and Max Length/Size for Textbox Rendering
body: <p>I know on the Razor View file, we can do something like this
  @Html.TextBox("username", null, new { maxlength = 20, autocomplete = "off" }) </p>
  
  <p>However, I am hoping to create a model for the MVC that can be used to create a form with explicitly defined the size and max length of the textboxes. I try [StringLength(n)] on top of the properties of the model, but that seems to only do the validation ratherh set the size of the textbox.</p>
  
  <p>Is there anyway that we can define the length of the text field as a data annotation on top of a property of a model? </p>
  
  <p>So ultimately, we could just create the whole form by using razor to map to a model rather than explicitly pick up the model properties one by one in order to set the textbox size.</p>