我试图在我的项目中使用Html.TextBoxFor设置一个TextBox控件.
但是,它似乎只有方法签名:
Lambda表达和价值:
<%= Html.TextBoxFor(t => t.ProjectDetails.Title,Model.ProjectDetails.Title)%>
要么
Lambda表达式和HtmlAttributes:
<%= Html.TextBoxFor(t => t.ProjectDetails.Title,new { maxlength = 10})%>
控件ID是已知的,这不是造型的问题:可以使用ProjectDetails_Title和样式表.但是,无法通过CSS设置maxlength,因为它是一种行为.
我知道你可以使用Html.TextBox指定所有三个,但是我想利用Html.TextBoxFor的额外功能.
任何想法,我如何设置一个值和一个最大长度的控件渲染使用Html.TextBoxFor?
感谢您的任何帮助!
解决方法
这应该在MVC4中工作.不确定MVC2.
@Html.TextBoxFor(t => t.ProjectDetails.Title,new { @maxlength="10",@class="myCssClass"})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。