NumericUpDownExtender 控件

功能:
    与TextBox控件联合用于增加或减少TextBox中的Value值。
属性:
      TargetControlID:该控件的目标作用控件。
      Width:该控件加上目标TextBox控件的宽度,要是不设定将看不到TextBox控件。
      RefValues:该控件中使用的一个字符串列,用于在TextBox中递增递减。
      ServiceUpPath:调用增加值的web方法时的路径。
      ServiceDownPath:调用减少值的web方法时的路径。
      ServiceUpMethod:调用增加值的web方法。
      ServiceDownMethod:调用减少值的web方法。
      TargetButtonUpID:自定义的增加值的控件按钮。
      TargetButtonDownID:自定义的减少值的控件按钮。

实例代码:
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head  runat ="server" >
    
< title > Untitled Page </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< center >< h1 > NumericUpDown控件的使用 </ h1 ></ center >
        
< asp:ScriptManager  ID ="ScriptManager1"  runat ="server" >
        
</ asp:ScriptManager >
    
   Enter a numeric value and use the up and down buttons to 
< br  /> increment/decrement(min:1 and max:7) &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;
   
< asp:TextBox  ID ="TextBox1"  runat ="server" ></ asp:TextBox >
          
< br  />
            
< br  />
            Choose your favorite month 
&nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;
            
&nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;   &nbsp;
           
< asp:TextBox  ID ="TextBox2"  runat ="server" ></ asp:TextBox >< br  />
            
< br  />
            Let the web service pick a random number between 0 and   
< br  />  1000 that is 
        higher/lower than the displayed value 
&nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp;
           
< asp:TextBox  ID ="TextBox3"  runat ="server" ></ asp:TextBox >< br  />
            
< br  />
                    Use the arrow images to increment/decrement the value 
&nbsp;
                    
< asp:TextBox  ID ="TextBox4"  runat ="server"  Height ="15px" ></ asp:TextBox >
            
< ajaxToolkit:NumericUpDownExtender  ID ="NumericUpDownExtender4"  TargetControlID ="TextBox4"  Width ="150"  TargetButtonUpID ="ImageButtonUp"  TargetButtonDownID ="ImageButtonDown"   runat ="server" >
            
</ ajaxToolkit:NumericUpDownExtender >
            
&nbsp;&nbsp;

           
< asp:ImageButton  ID ="ImageButtonDown"  runat ="server"  Width ="15px"  Height ="15px"  ImageUrl ="~/Images/ArrowDown01.gif"   /> &nbsp;
            
            
< asp:ImageButton  ID ="ImageButtonUp"  runat ="server"  Width ="15px"  Height ="15px"  ImageUrl ="~/Images/ArrowUp01.gif"   />   &nbsp; < br  />
            
< ajaxToolkit:NumericUpDownExtender  ID ="NumericUpDownExtender1"  TargetControlID ="TextBox1"  Width ="150"  Minimum =1  Maximum =7   runat ="server" >
            
</ ajaxToolkit:NumericUpDownExtender >
            
< ajaxToolkit:NumericUpDownExtender  ID ="NumericUpDownExtender2"  TargetControlID ="TextBox2"  Width ="150"  RefValues ="January;February;March;April;May;June;July;August;September;October;November;December"  runat ="server" >
            
</ ajaxToolkit:NumericUpDownExtender >
            
< ajaxToolkit:NumericUpDownExtender  ID ="NumericUpDownExtender3"  TargetControlID ="TextBox3"  Width ="150"  ServiceUpPath ="WebServiceNumbericUpDown.asmx"  ServiceUpMethod ="PreNumber"  ServiceDownPath ="WebServiceNumbericUpDown.asmx"  ServiceDownMethod ="NextNumber"  Tag ="3"  runat ="server" >
            
</ ajaxToolkit:NumericUpDownExtender >
    
</ form >
</ body >
</ html >
WebService代码如下:
public   class  WebServiceNumbericUpDown : System.Web.Services.WebService  {

    
public WebServiceNumbericUpDown () {

        
//Uncomment the following line if using designed components 
        
//InitializeComponent(); 
    }



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

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

}


运行结果:
        
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值