博客园 首页 联系 订阅 管理
 
2008-03-01 22:16

二十.NumericUpDown

NumericUpDown 是一个可以使得 ASP.Net TextBox 控件具有可控制其中值的“向上”和“向下”按钮的 ASP.Net AJAX 控件。

以最简单的方式,“向上”按钮将使得 TextBox 中的值加一,“向下”按钮将使得 TextBox 中的值减一。 而 NumericUpDown 同样具有可以指定其“增长”和“减少”动作的方式,包括:

  • 提供一系列的数值,例如上面的月份,使得其在这些数值中进行变化
  • 从 Web Service 中获得“向上”或者“向下”的值

除此之外,开发人员还可以指定两个个性化的图片表示其“向上”和“向下”按钮

NumericUpDown 属性

NumericUpDown 控件属性将被初始化如下面的示例代码所示,斜体属性为可选属性

<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 - 需要被扩展的 TextBox 控件 ID
  • Width - 出现的“向上”和“向下”按钮的值,最小值是 25,当采用自定义按钮方式的时候,该属性无效
  • RefValues - 一系列可提供给“增长”和“减少”动作的数值,以分号 (;) 对每一个数值进行分割
  • Step - 当采用于简单的数字方式时,每一次点击“向上”或“向下”按钮时,增加或者减少的值,默认值是 1
  • TargetButtonDownID/TargetButtonUpID - 自定义的“向上”或“向下”按钮的控件 ID
  • ServiceDownPath/ServiceUpPath - “增长”或者“减少”的 Web Service 路径, 当调用的 Web Service 方法为页面方法时,可以将这个属性设为空,另外 Web Service 类定义的时候,必须增加一个 System.Web.Script.Services.ScriptService 属性修饰。
  • ServiceDownMethod/ServiceUpMethod - “增长”或者“减少”的 Web Service 方法名, 如果是本页面上的 Web Service 方法,必须增加一个 WebMethodAttribute 属性修饰。同时需要按照下面的格式定义方法签名:
    [System.Web.Services.WebMethod]
                    [System.Web.Script.Services.ScriptMethod]
                    public int NextValue(int current, string tag) { ... }
posted on 2009-01-01 14:09  jason618  阅读(218)  评论(0编辑  收藏  举报