Altas (Ajax) control (19): Up and DOWN arrow button control NumericUpDown

Source: Internet
Author: User
Tags min

First, Introduction

NumericUpDown can also be called a micro-regulator (effect graph:), which can be used to perform a set of input controls about the values in the sequence. As early as in the Delphi era, it was popular to use the control. But on the web, to today only really appear the secondary control, it can be seen that the web implementation of the difficult, thanks to Ajax.

NumericUpDown is also an extended control, which extends the textbox. Regular use has a number of increases/minus and time/date/week of increase/decrease. and the picture of its up and down keys can be changed.

There are three ways to increase/subtract (as I know):

1. Enumerate in the list.

2. Set the maximum, minimum, and stride size in the attribute.

3. The method of mapping the increment/decrement in the webservice.

Second, Property Description

<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"/>

targetcontrolid– the ID of the expanded textbox

Width-the textbox of the control extension plus the width of the up and down button keys (the minimum value is 25).

refvalues– if you want to increment/subtract in an enumeration way. Then set the enumeration value in this value, using ";" Segmentation. such as: "Monday; Tuesday; Wednesday; Thursday; Friday; Saturday; Sunday"

step– step, increment/decrement length of each time. The default value is 1.

targetbuttondownid/targetbuttonupid– the ID of the up/down button.

servicedownpath/serviceuppath– the physical path of the webservice of the method that places the up/down buttons.

Servicedownmethod/serviceupmethod-Method of the up/down button in WebService:

You need to place a declaration before the WebService method

[System.Web.Services.WebMethodAttribute (), System.Web.Script.Services.ScriptMethodAttribute ()]

TAG-A parameter passed to the Web method specified by Servicedownmethod or Serviceupmethod, which can be used to pass the current context information to the server.

Consumed by minimum value.

Maximum-Maximum value.

Third, Example

1. Enumerating in the list

<asp:textbox id= "TextBox2" runat= "Server" > Wednesday </asp:TextBox>
<cc1:numericupdownextender id= "NumericUpDownExtender1" runat= "Server" width=100 targetcontrolid= "TextBox2"
Refvalues= "Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday" >

2. Set the maximum, minimum, and step size in the attribute

<asp:textbox id= "TextBox2" runat= "Server" >10</asp:TextBox>
&nbsp;&nbsp;
<cc1:numericupdownextender id= "NumericUpDownExtender1" runat= "Server" maximum= "1000"
minimum= "0" step= "targetcontrolid=" TextBox2 "width=" >
</cc1:NumericUpDownExtender>

3. how to map the increment / decrement in WebService

We can add two methods to a Numericupdownextende control

numericupdown. asmx code example:

Using System;
Using System.Web;
Using System.Collections;
Using System.Web.Services;
Using System.Web.Services.Protocols;


/**////<summary>
///NumericUpDownSummary description of
</summary>
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]
[System.Web.Script.Services.ScriptService]
public classNumericUpDown: System.Web.Services.WebService ... {

[WebMethod]
public int NextValue (int current, stringTag) ... {
return new Random (). Next (Math.min (Math.max (0, current)), 1001);
}

[WebMethod]
public int Prevvalue (int current, stringTag) ... {
return new Random (). Next (0, Math.min (Math.max (0, current)));
}

}

This allows you to control the execution of the up and down keys.

Http://asp.net/AJAX/Control-Toolkit/Live/NumericUpDown/NumericUpDown.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.