asp.net-mvc-3 – 是否可以设置TextBoxFor生成的输入类型

我正在使用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)

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...