ASP.NET中的HTML5类型 [英] HTML5 Types in ASP.NET
问题描述
网站将专门用于移动设备。因此对于只需要数字输入的字段,我想调出数字键盘。我可以通过使用类型设置为 tel
的html输入元素来成功完成此操作。我想在此字段中添加 asp:RequiredFieldValidator
并基于 MSDN 。
Site will exclusively be used on mobile devices. So for fields requiring only numeric input, I want to bring up the numeric keypad. I can successfully do this by using an html input element with the type set to tel
. I want to add an asp:RequiredFieldValidator
to this field and based on MSDN.
我需要将输入设置为 runat =server
。当我这样做时,我收到此错误;
I need to set the input to runat="server"
. When I do this, I get this error;
tel
无效输入标记的类型。
tel
is not a valid type for an input tag.
如果我删除 runat =server
,我得
无法找到控制ID
合约
由<$引用c $ c> ControlToValidate 属性''
这是我的代码:
<input type="tel" runat="server" id="Contract"></input>
<asp:RequiredFieldValidator runat="server" ControlToValidate="Contract"
ValidationGroup="IfOnRent" Text="*"
ErrorMessage="Contract Required">
</asp:RequiredFieldValidator>
我只是运气不好并且必须编写我自己的验证码?
Am I just out of luck and have to code my own validations?
推荐答案
您可能希望在代码front中保留typeunclared。你可以在后面的代码中设置它(可能在 Page_Init
或 Page_Load
):
You may want to leave "type" undeclared in your code "front". You can set this in the code behind (maybe in the Page_Init
or Page_Load
):
this.Contract.Attributes.Add("type", "tel");
这篇关于ASP.NET中的HTML5类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!