How to set a default value with Html.TextBoxFor?
Posted
by dcompiled
on Stack Overflow
See other posts from Stack Overflow
or by dcompiled
Published on 2010-06-14T04:41:43Z
Indexed on
2010/06/14
4:52 UTC
Read the original article
Hit count: 612
Simple question, if you use the Html Helper from ASP.NET MVC Framework 1 it is easy to set a default value on a textbox because there is an overload Html.TextBox(string name, object value)
. When I tried using the Html.TextBoxFor method, my first guess was to try the following which did not work:
<%: Html.TextBoxFor(x => x.Age, new { value = "0"}) %>
Should I just stick with Html.TextBox(string, object) for now?
© Stack Overflow or respective owner