zoukankan      html  css  js  c++  java
  • altas(ajax)控件(十九):上下箭头按钮控件NumericUpDown

    一、      简介

    NumericUpDown也可以称之为微调控件(效果图: ,可以使用它进行一组有关联顺序的值的输入控件。早在delphi时代,就流行使用该控件。而在web上,到今天才真正出现次控件,可见其web实现之难,感谢ajax

    NumericUpDown同样也是扩展控件,它扩展的是TextBox。常规的使用有数字的增/减和时间/日期/星期的的增/减。而且它的上下键的图片还可以更改。

    它的增/减方式有三种(我所知道的):

    1.在列表中枚举。

    2.在属性中设置最大、最小值和步长。

    3.WebService中映射/减的方法。

     

    二、       属性说明

     

    <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被扩展的TextBoxID

    Width -控件扩展的TextBox加上上下按钮键的Width (最小值是 25).

    RefValues如果你希望以枚举的方式来/减。那么在这个值中设置枚举值,用”;”分割。如"星期一;星期二;星期三;星期四;星期五;星期六;星期天"

    Step步长,每次的/减的长度.默认值是1.

    TargetButtonDownID/TargetButtonUpID上下/减按钮的ID.

    ServiceDownPath/ServiceUpPath放置上下/减按钮的方法的WebService的物理路径。

    ServiceDownMethod/ServiceUpMethod - 上下/减按钮在WebService的方法:

    WebService的方法前需要放置声明

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

    Tag - 传递给ServiceDownMethodServiceUpMethod所指定的Web Method的参数,可用于传递给服务器当前的上下文信息。

    Minimum最小值.

    Maximum -  最大值.

     

    三、       实例

     

    1.在列表中枚举

    <asp:TextBox ID="TextBox2" runat="server">星期三</asp:TextBox>
              <cc1:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server"   Width=100 TargetControlID="TextBox2"
              RefValues="
    星期一;星期二;星期三;星期四;星期五;星期六;星期天"     >

    2. 在属性中设置最大、最小值和步长

    <asp:TextBox ID="TextBox2" runat="server">10</asp:TextBox>
         &nbsp;&nbsp;
         <cc1:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" Maximum="1000"
             Minimum="0" Step="50" TargetControlID="TextBox2" Width="100">
         </cc1:NumericUpDownExtender>

    3.WebService中映射/减的方法

    我们可以为NumericUpDownExtende控件添加两个方法

    NumericUpDown.asmx代码示例:

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;


    /**//// <summary>
    /// NumericUpDown 
    的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class NumericUpDown : System.Web.Services.WebService ...{

        [WebMethod]
        
    public int NextValue(int current, string tag...{
            
    return new Random().Next(Math.Min(1000, Math.Max(0, current)), 1001);
        }

        [WebMethod]
        
    public int PrevValue(int current, string tag...{
            
    return new Random().Next(0, Math.Min(1000, Math.Max(0, current)));
        }
        
    }

    这样就可以控制上下键的执行过程。

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

     

     
  • 相关阅读:
    科学-化学:化学百科
    科学-物理:物理学 (自然科学学科)百科
    科学-建筑学-建筑美学:建筑美学百科
    科学-建筑学:建筑学百科
    科学-哲学-美学:美学(中国哲学二级学科)
    哲学:哲学(世界观学说、社会形态之一)
    科学-语文:语文(语言和文学的简称)
    科学-分析:分析
    建模:数学建模
    科学-数学:数学
  • 原文地址:https://www.cnblogs.com/hainange/p/6153325.html
Copyright © 2011-2022 走看看