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.)
I'm writing this from memory, but I think it's:
qtybox.Attributes.Add("type", "number");
For anyone still coming here with the same problem, a few months after the OP opened this question Microsoft released an update that fixes the problem:
http://support.microsoft.com/kb/2533523 (see issue number 12).
For Visual Studio 2010, if you try to install it and it says it doesn't apply to you, check that you have VS2010 SP1. In that case, simply installing SP1 may solve the problem. The download can be found at http://www.microsoft.com/en-us/download/details.aspx?id=23691.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With