Setting maxlength and other html attributes using ASP.NET MVC helper methods -


Currently, when I want to set the maximum length of HTML properties and automatically complete, use the following syntax Will be:

  & lt;% = Html.TextBox ("user name", see data ["user name"], new {maxlength = 20, auto-integer = "off"})% & Gt;  

Is there any way to explicitly do this without setting ViewData ["username"] part? In other words, I am clearly saying this is to rely on the automated loading routine of the subsidiary method to load which field from ViewData.

Just pass the "null" as the second parameter:

  & Lt;% = Html.TextBox ("user name", blank, new {maxlength = 20, autocomplete = "off"})%>  

Comments