zoukankan      html  css  js  c++  java
  • AJAX Control Toolkit–NumericUpDown

    1.NumericUpDown Server Reference

    TagetControlIDThe ID of the TextBOx to modify.(要扩展的文本框ID)

    Width - Combined size of the TextBox and Up/Down buttons (min value 25). This property is not used if you provide custom buttons.(文本框和增减按钮的总宽度(最小值为25px)当用户设置自定义按钮时该属性无效)

    RefValues - A list of strings separated by semicolons (;) to be used as an enumeration(枚举) by NumericUpDown(看例子就很明了了)

    StepStep used for simple numeric incrementing(增) and decre(减).The default value is 1.

    TargetButtonDownID/TargetButtonUpID - Reference to custom Up/Down buttons.(用户自定义的增减按钮)

    ServiceDownPath/ServiceUpPath - Path to a web service that returns the data used to get the next or previous value. This property should be left null if ServiceUpMethod or ServiceDownMethod refers to a page method. The web service should be decorated with the System.Web.Script.Services.ScriptService attribute.

    ServiceDownMethod/ServiceUpMethod - Web service method that returns the data used to get the next or previous value, or the name of a method declared on the Page which is decorated with the WebMethodAttribute. The signature of this method must match the following:

    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public int NextValue(int current, string tag) { ... }

    Note you can replace "NextValue" with a name of your choice, but the return type and parameter name and type must exactly match, including case.

    Tag – Specifies a custom parameter to pass to the Web Service

    Minimum - The minimum value allowed by the extender. Currently, it does not prevent out of range values from being entered into the textbox even if Minimum or Maximum are specified on the extender, but using the up/down buttons should bring the value into the allowed range when clicked.

    Maximum - The maximum value allowed by the extender.

    Demo>>

     1 <form id="form1" runat="server">
    2 <asp:ScriptManager ID="ScriptManager1" runat="server" />
    3 <div style="text-align: center">
    4 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    5 <ContentTemplate>
    6 <br /><br />
    7 Enter a numeric value and use the up and down buttons to increment/decrement <br /><br />
    8 <asp:TextBox ID="TextBox1" runat="server" Text="3" Width="120" style="text-align:center" /><br /><br />
    9
    10 Choose your favorite month<br /><br />
    11 <asp:TextBox ID="TextBox2" runat="server" Text="June" Width="120" style="text-align:center" /><br /><br />
    12
    13 Let the web service pick a random number between 0 and 1000 that is higher/lower than the displayed value<br /><br />
    14 <asp:TextBox ID="TextBox3" runat="server" Text="500" Width="120" style="text-align:center" /><br /><br />
    15
    16 Use the arrow images to increment/decrement the value<br /><br />
    17 <asp:TextBox ID="TextBox4" runat="server" Text="0" Width="70" style="text-align:center" />
    18 <asp:Image ID="img1" runat="server" ImageUrl="~/images/down.gif" AlternateText="Down" Width="20" Height="15"/>
    19 <asp:Image ID="img2" runat="server" ImageUrl="~/images/up.gif" AlternateText="Up" Width="20" Height="15"/><br /><br />
    20 <br />
    21
    22 <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /><br /><br />
    23
    24 <asp:Label ID="Label1" runat="server" Text="[No response provided yet]" />
    25
    26 <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server"
    27 TargetControlID="TextBox1"
    28 Width="120"
    29 RefValues=""
    30 ServiceDownMethod=""
    31 ServiceUpMethod=""
    32 TargetButtonDownID=""
    33 TargetButtonUpID="" />
    34 <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender2" runat="server"
    35 TargetControlID="TextBox2"
    36 Width="120"
    37 RefValues="January;February;March;April;May;June;July;August;September;October;November;December"
    38 ServiceDownMethod=""
    39 ServiceUpMethod=""
    40 TargetButtonDownID=""
    41 TargetButtonUpID="" />
    42 <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender3" runat="server"
    43 TargetControlID="TextBox3"
    44 Tag=""
    45 Width="120"
    46 ServiceUpPath="NumericUpDown.asmx"
    47 ServiceDownPath="NumericUpDown.asmx"
    48 ServiceUpMethod="NextValue"
    49 ServiceDownMethod="PrevValue"
    50 RefValues=""
    51 TargetButtonDownID=""
    52 TargetButtonUpID="" />
    53 <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender4" runat="server"
    54 TargetControlID="TextBox4"
    55 Width="80"
    56 TargetButtonDownID="img1"
    57 TargetButtonUpID="img2"
    58 RefValues=""
    59 ServiceDownMethod=""
    60 ServiceUpMethod="" />
    61 </ContentTemplate>
    62 </asp:UpdatePanel>
    63 </div>
    64 </form>

     >>NumericUpDown.asmx.cs

     1 using System;
    2 using System.Web;
    3 using System.Collections;
    4 using System.Web.Services;
    5 using System.Web.Services.Protocols;
    6
    7
    8 /// <summary>
    9 /// Summary description for NumericUpDown
    10 /// </summary>
    11 [WebService(Namespace = "http://tempuri.org/")]
    12 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    13 [System.Web.Script.Services.ScriptService()]
    14 public class NumericUpDown : System.Web.Services.WebService {
    15
    16 public NumericUpDown () {
    17
    18 //Uncomment the following line if using designed components
    19 //InitializeComponent();
    20 }
    21
    22 [WebMethod]
    23 public int NextValue(int current, string tag)
    24 {
    25 Random rand = new Random();
    26 return rand.Next(Math.Min(1000, Math.Max(0, current)), 1001);
    27 }
    28
    29 [WebMethod]
    30 public int PrevValue(int current, string tag)
    31 {
    32 Random rand = new Random();
    33 return rand.Next(0, Math.Min(1000, Math.Max(0, current)));
    34 }
    35
    36 }
    1 protected void Button1_Click(object sender, EventArgs e)
    2 {
    3 Label1.Text = String.Format("Value: <b>{0}</b><br>Month: <b>{1}</b><br>Random Value: <b>{2}</b><br>Value: <b>{3}</b>", TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text);
    4 }

      

     

  • 相关阅读:
    OO设计精要:封装,还是封装(有感于“Why getter and setter methods are evil ”by Allen Holub )
    博客园建议:能否记住在博客园的首页上只显示标题
    戴尔国际英语
    C#代码契约(转)
    C#数组传递和返回
    SecureString
    里氏替换原则
    ASP.NET的Cache(转)
    WCF服务
    C#枚举中的位运算权限分配
  • 原文地址:https://www.cnblogs.com/January/p/2135861.html
Copyright © 2011-2022 走看看