是否有可能设置由TextBoxFor产生的输入型 [英] Is it possible to set type of input generated by TextBoxFor
本文介绍了是否有可能设置由TextBoxFor产生的输入型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ASP.NET MVC 3 TextBoxFor的形式,并想用TYPE =电子邮件更容易输入至少一些移动设备,但无法找到如何使用TextBoxFor来设置。这是不容易可能吗?
I am using ASP.NET MVC 3 TextBoxFor in a form and would like to use type="email" for easier input for at least some mobile devices but cannot find how to set it using TextBoxFor. Is this not easily possible?
在View
@Html.LabelFor(m => m.Email)
@Html.TextBoxFor(m => m.Email)
在模型
[StringLength(50)]
public string Email { get; set; }
(已使用数据标注,以保护数据库的大小限制)
(Already using a data annotation to protect size constraint in DB)
推荐答案
尝试使用
@Html.TextBoxFor(m => m.Email, new { @type = "email" })
<一个href=\"http://msdn.microsoft.com/en-us/library/ee703538.aspx\">http://msdn.microsoft.com/en-us/library/ee703538.aspx (htmlAttributes)
http://msdn.microsoft.com/en-us/library/ee703538.aspx (htmlAttributes)
这篇关于是否有可能设置由TextBoxFor产生的输入型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文