我正在使用ASP.NET MVC 3 TextBoxFor的形式,并希望使用type =“email”为至少一些移动设备更容易的输入,但是找不到如何使用TextBoxFor来设置它。这不容易吗?
在视图中
@Html.LabelFor(m => m.Email) @Html.TextBoxFor(m => m.Email)
在模型中
[StringLength(50)] public string Email { get; set; }
(已经使用数据注释来保护DB中的大小约束)
解决方法
尝试使用
@Html.TextBoxFor(m => m.Email,new { @type = "email" })
http://msdn.microsoft.com/en-us/library/ee703538.aspx(htmlAttributes)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。