Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 2 EditorFor MaxLength and Size

Tags:

asp.net-mvc

How do you set the MaxLength and Size of a TextBox in MVC 2? There have been a couple of questions asked about this on SO. As a newcomer to MVC I am finding that none of the solutions appear to work - possibly because I am not doing it right.

In any case I am wondering if there are better solutions since the previous questions appear to be asked at a time when MVC 2 was in beta.

like image 856
arame3333 Avatar asked Aug 12 '10 09:08

arame3333


1 Answers

It's easy, you just to have extra htmlAtttributes

<%= Html.TextBoxFor(model => model.Member, new { maxlength = "20", width = "15" }) %> 
<%= Html.TextBoxFor(model => model.Member, new { maxlength = "20", style = "width:200px;" }) %> 
like image 108
Łukasz W. Avatar answered Nov 19 '22 03:11

Łukasz W.