HTML5 email input cannot assign ID and RUNAT=“Server” ASP.NET 4

后端 未结 4 567
轻奢々
轻奢々 2020-11-30 13:39

Hi I am trying to assign an ID to an HTML5 input so that i can access its value from the code behind in the web form. However with the this code:

 

        
4条回答
  •  青春惊慌失措
    2020-11-30 14:17

    ASP.Net 4.0 HtmlGenericControl does not support the "Type" attribute as defined in your code, the error explains that, Parser Error Message: 'email' is not a valid type for an input tag., this is a arguably a "well known" or easily discovered bug in the ASP.Net framework.

    There are several solutions that are outlined here:
    http://msdn.microsoft.com/en-us/magazine/hh547102.aspxre
    Update the framework and use the Asp.Net TextBox control Scott Hunter - HTML 5 Updates for .NET 4
    Use a 3rd party ASP.Net Html5 UI control such as the one available from Codeplex.

    A similar question is asked, and answered on the following SO posts:
    How can I use HTML5 email input type with server-side .NET - This is the same issue as for the HtmlGenericControl however it is not addressed in the update
    input types on server side controls


    My personal preference ended up being to move to ASP.Net MVC 3, its quite a steep learning curve and a big change from the "Web Forms" style of ASP.Net web development however its soon forgotten once you get used to the symantics and coding styles.

提交回复
热议问题