HTML5 电子邮件输入无法分配 ID 且 RUNAT=“服务器"ASP.NET 4 [英] HTML5 email input cannot assign ID and RUNAT="Server" ASP.NET 4

查看:20
本文介绍了HTML5 电子邮件输入无法分配 ID 且 RUNAT=“服务器"ASP.NET 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试为 HTML5 输入分配一个 ID,以便我可以从 Web 表单后面的代码中访问它的值.但是使用此代码:

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:

 <input type="email" required autofocus placeholder="Email Address" class="txt-input txt-input-username" ID="myTextBox" runat="server" />

Visual Studio 2010 告诉我它无法解析符号 ID="myTextBox".

Visual Studio 2010 is telling me that it cannot resolve the symbol ID="myTextBox".

关于如何解决这个问题的任何想法,因为我已经寻找了将近一天的答案?谢谢

Any ideas on how i can fix this because i have been searching for an answer for nearly a day? thanks

推荐答案

ASP.Net 4.0 HtmlGenericControl 不支持您的代码中定义的Type"属性,错误说明,Parser Error Message: 'email' 不是输入标签的有效类型.,这可以说是 ASP.Net 框架中的一个众所周知的"或很容易发现的错误.

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.

这里概述了几种解决方案:
http://msdn.microsoft.com/en-us/magazine/hh547102.aspxre
更新框架并使用 Asp.Net TextBox 控件 Scott Hunter - .NET 4 的 HTML 5 更新
使用 第 3 方 ASP.Net Html5 UI 控件,例如 Codeplex 提供的控件.

提出了类似的问题,并在以下 SO 帖子中得到了回答:
如何使用 HTML5 电子邮件输入类型使用服务器端 .NET - 这与 HtmlGenericControl 的问题相同,但在更新中没有解决
服务器端控件的输入类型

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


我个人的偏好最终是转向 ASP.Net MVC 3,它的学习曲线相当陡峭,并且与 ASP.Net Web 开发的Web 窗体"风格相比发生了很大变化,但是一旦您习惯了语义和编码风格,它很快就会被遗忘.


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.

这篇关于HTML5 电子邮件输入无法分配 ID 且 RUNAT=“服务器"ASP.NET 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆