使用asp .net TextBox的iPhone电子邮件键盘布局

Mic*_*ael 3 asp.net iphone

你知道iDevices如何根据type属性的HTML 5值显示不同的键盘布局吗?因此,<input type="email"...将显示iPad的电子邮件键盘布局.我正在使用.net TextBox,但希望iDevices显示该字段的相应键盘布局.但是当TextBox控件呈现时,type属性会被覆盖为"text".有任何想法吗?

Jan*_*oom 6

没有简单的解决方法,但你可以创建一些新的控件,如:

public EnhancedTextBox : TextBox {
     public Html5Type Html5Type { get; set; }

     override AddAttributesToRender(HtmlTextWriter writer) {
           // add attribute according to the selected type in the property
           // something like
           writer.AddAttribute("type", "email");
           base.AddAttributesToRender(writer);
     }
}
Run Code Online (Sandbox Code Playgroud)

并使用它而不是普通的TextBox


Chr*_*ver 5

.NET framework 4有一个更新,允许您指定type属性.

http://support.microsoft.com/kb/2468871.

请参阅页面下方的功能3

Feature 3

New syntax lets you define a TextBox control that is HTML5 compatible. For example, the following code defines a TextBox control that is HTML5 compatible:

<asp:TextBox runat="server" type="some-HTML5-type" />
Run Code Online (Sandbox Code Playgroud)