I have a dynamically created TextBox in a C#/ASP.NET web page that I want to adapt to mobile browsers:
TextBox qtybox = new TextBox();
qtybox.ID="qtybox";
qtybox.Text = "0";
qtybox.Width = 30;
container.Controls.Add(qtybox);
I see that I can directly set this in a plain HTML <form>
:
<input type="number">
...which will then bring up the numeric keyboard.
How can I do this with my dynamic TextBox in the codebehind, or can I?
Is there an alternate way to put a numeric input control on my page dynamically from the codebehind that would work better? Do I need to use JavaScript to "hack" the control after it renders? (I'd rather have a .NET way of doing it if possible.)