Is there any Html.TextBoxFor overload implementation which allows value formatting?
I know about EditorFor and DataFormatString but it is not what I开发者_运维问答 am looking for.
Why not use an EditorTemplate? Of course, if you're going to use different ways of formatting the same objects you're going to have to use the template name in the call to EditorFor()
(so it'll look like EditorFor(object, "TemplateName")
.
Another option is to add your own HTML Helper. The MVC source code is open so you can download the RTM sources for 2/3 and look at how Html.TextBoxFor()
is implemented.
I think EditorFor()
is the correct solution to this problem. Why don't you want to use it?
It is possible in ASP.NET MVC 4: http://forums.asp.net/p/1720963/4599128.aspx/1?Html+TextBoxFor+value+formatting
精彩评论