Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a numeric UpDown control for ASP.NET?

Tags:

html

asp.net

Is there a way I can use a numeric updown in ASP.NET without using JavaScript?

And if not, is there an alternative?

like image 343
HelpASisterOut Avatar asked May 14 '13 08:05

HelpASisterOut


People also ask

What is NumericUpDown control in C#?

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 .

What is the property that determines by how much the current number in a NumericUpDown control changes when the user clicks the up arrow or the down arrow?

The Increment property sets the amount that the number is adjusted by when the user clicks an up or down arrow.

How do you use NumericUpDown in Visual Basic?

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.


2 Answers

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" />
like image 188
Alicia Avatar answered Oct 04 '22 07:10

Alicia


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

like image 30
LukeHennerley Avatar answered Oct 04 '22 07:10

LukeHennerley