Is there a way I can use a numeric updown in ASP.NET without using JavaScript?
And if not, is there an alternative?
A NumericUpDown control contains a single numeric value that can be incremented or decremented by clicking the up or down buttons of the control. The user can also enter in a value, unless the ReadOnly property is set to true .
The Increment property sets the amount that the number is adjusted by when the user clicks an up or down arrow.
Drag and drop NumericUpDown Control from the toolbox on window Form. By Default Maximum and Minimum value in NumericUpDown Control is set 100 and 0 respectively. You can also set Maximum and Minimum value in NumericUpDown Control. To show the value in NumericUpDown.
I was trying to do the same thing, and it turns out the asp textbox has an option for it. what worked for me was this:
<asp:TextBox TextMode="Number" runat="server" min="0" max="20" step="1"/>
this gave me a textbox which, when mouse hovers over it or is given focus, shows the up-down controls, and only allows numbers from min to max. it works the same as
<input type="number" min="0" max="20" step="1" />
Please look into the Ajax Control Toolkit
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/NumericUpDown/NumericUpDown.aspx
<ajaxToolkit:NumericUpDownExtender ID="NUD1" runat="server"
TargetControlID="TextBox1"
Width="100"
RefValues="January;February;March;April"
TargetButtonDownID="Button1"
TargetButtonUpID="Button2"
ServiceDownPath="WebService1.asmx"
ServiceDownMethod="PrevValue"
ServiceUpPath="WebService1.asmx"
ServiceUpMethod="NextValue"
Tag="1" />
Also consider adding the reference with NuGet by using PM> Install-Package AjaxControlToolkit
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