SollyM SollyM - 1 year ago 86
ASP.NET (C#) Question

How do I force ASP:TextBox to be of type email?

I have an

application and I'd like to add the
according to
standards but if I add the type on the
control I get the below output:

<input name="ctl00$content$txtEmailAddress" type="text" type="email" value=""
id="ctl00_content_txtEmailAddress" class="input-block-level" required="required"/>

How can I replace the type attribute from "text" to "email"?

Answer Source

If you using .Net 3.5 then no matter what type you have specified with <asp:TextBox>, it will always render with <input type="text" />. So in that case you can use simple html input with type="email"

<input type="email" />

For 4.5 version you can use TextMode="Email"

<asp:TextBox ID="txtmyBox" runat="server" TextMode="Email"></asp:TextBox>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download