Skip to content Skip to sidebar Skip to footer

Html5 Types In Asp.net

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 inpu

Solution 1:

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");

Solution 2:

If you have Microsoft .NET Framework 4 Reliability Update 1 (KB2533523) installed, than TextBox accepts new html5 input types (you would need it for UpdatePanel to recognize them on postback too).

Or you can just inherit HtmlInputText in your own control (any .net version - any input type):

[ToolboxData("<{0}:Input runat='server' />"), Themeable(true)]
publicsealedclassInput: HtmlInputText { }

Solution 3:

If you are using C#

Contract.Attributes["type"]="tel"

Writing inline types for html inputs may produce parse error in .net. So add the above line of code in your PageLoad()

Solution 4:

you can use Make sure that the submit button has the same validationgroup property value as the requiredfieldvalidator

Post a Comment for "Html5 Types In Asp.net"