NumericUpDown control for ASP.Net, Does anyone have any ready to use?

jcl0101

Member
Joined
May 29, 2010
Messages
6
Programming Experience
Beginner
I have visited hundreds of sites through Google, looking for some instruction "Logic" and serious about how to make a NumericUpDown control for ASP.Net, but apparently is a very well-guarded secret, because I have nowhere find something. Does anyone here have some instructive insight into what I do for a NumericUpDown Control for ASP.Net? On several occasions I have found very good solutions here, I hope that this time is the same. Thank you very much in advance. :cool:
 
You can't really. ASP.NET is limited by HTML and browser support. An ASP.NET server control is not the same as a WinForms control, where you can make it look like and do whatever you want. An ASP.NET server control is just a tag that, when processed by ASP.NET, causes certain HTML code to be generated. There's no NumericUpDown control in HTML so there's no NumericUpDown control in ASP.NET. The best you could manage would be a TextBox with two Buttons and some JavaScript to increment decrement the value in the TextBox when the Buttons are clicked.
 
Thank you very much. No doubt you have an excellent knowledge of ASP.Net.
You're right, and here is your idea materialized.

The Code:
---------------------------------
<input type="button" value='-' onclick='javascript:decrement(-1)' />
<asp:TextBox ID="t1" runat="server" Text="1">
</asp:TextBox>
<input type="button" value='+' onclick='javascript:increment(1)' />

<script type="text/javascript" language="javascript">
function decrement(val) {
if (document.getElementById("t1").value != 1) {
document.getElementById("t1").value = parseInt(document.getElementById("t1").value) + val;
}
}
function increment(val) {
//alert(Date);
document.getElementById("t1").value = parseInt(document.getElementById("t1").value) + val;
}
</script>
---------------------------------


Thanks.
 
The Ajax Control ToolKit includes a NumericUpDown extender, shown here NumericUpDown Sample
Current versions is for .Net 3.5 and .Net 4.0, but there is also an old version available for .Net 2.0 - though if it had the NUD I can't say.
 
I have visited hundreds of sites through Google, looking for some instruction "Logic" and serious about how to make a NumericUpDown control for ASP.Net, but apparently is a very well-guarded secret, because I have nowhere find something.
Interesting.

numericupdown asp.net - Google Search

The first result for me is a page about the very control JohnH mentions and the second is a video on how to use it.
 
Back
Top