Did you know that you can use HTML5 input types with ASP.NET WebForms controls? I wasn't sure until I tried it today:
<asp:TextBox runat="server" ID="Username" Width="250px" type="email" />
which properly produces this HTML5 compliant HTML output:
<input type="email" style="width:250px;" id="Username" name="Username">
That this works shouldn't come as a big surprise since ASP.NET always has supported 'extra' attributes on Web Controls to render into the HTML. However, the input type seems like a pretty core feature in input controls and the control does have a TextMode property that already partially addresses this task. Nevertheless, explicitly specifying the type attribute allows you to override the type and so provide custom HTML 5 input types.
In short - nice! HTML5 input types are supported in WebForms without any framework changes or updates.[updated from comments]Apparently, in order for this to work you need an update for for the .NET 4 runtimes which was shipped with Visual Studio 2010 SP1. However on live servers you might have to install the Hotfix described in the previous link. I say might, because this code worked on my live server and I didn't explicitly install the hotfix - it appears that some of the .NET 4 updates through Windows Update must have addressed this. To be sure you should test a page that holds controls with HTML5 types to ensure the server will handle this - if not install the hotfix.
I'll be at DevIntersection in Vegas this fall giving sessions on ASP.NET Core with Angular and Localization. Thinking of coming? Use discount code STRAHL and save a few bucks. If you do be sure to stop by and say hello!
Other Posts you might also like