This can be done using a custom control. Here you go ...
namespace CustomTextBoxControls { public class TextBoxWithType : TextBox { public string modifyType { get; set; } protected override void Render(System.Web.UI.HtmlTextWriter output) { if (!string.IsNullOrEmpty(modifyType)) { output.AddAttribute("type", modifyType); } base.Render(output); } } }
Register it on the aspx page ..
<%@ Register Namespace="CustomTextBoxControls" TagPrefix="CustomControl" Assembly="CustomTextBoxControls" %> <CustomControl:MaskedTextBoxWithType id="txtNumber" modifyType="number" runat="server"></CustomControl:MaskedTextBoxWithType>
The type attribute will be taken from the modifyType property above. Thus, it can also be a currency or any other type with HTML5 support.
Ratikanta Naik
source share