NumericUpDownExtender

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>NumericUpDownExtender</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
          Enter a numeric value and use
         <br />
         the up and down buttons to increment/decrement &nbsp; &nbsp; &nbsp;<asp:TextBox ID="TextBox1"
            runat="server">0</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;
          <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
         <br />
            Let the web service pick a random number
           <br />
            between 0 and 1000 that is higher/lower
          <br />
            than the displayed value &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
           &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp;
           <asp:TextBox ID="TextBox3" runat="server">0</asp:TextBox><br />
           <br />
           Use the arrow images to increment/decrement &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;
            <br />
             the value &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            <asp:TextBox ID="TextBox4" runat="server" ></asp:TextBox>
            <asp:ImageButton ID="ImageButton2" runat="server" Width="15px" Height="15px" ImageUrl="~/up.gif" />
            &nbsp;
            <br />
            &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; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            <asp:ImageButton ID="ImageButton1" runat="server" Width="15px" Height="15px" ImageUrl="~/down.gif" /><br />
               <cc1:NumericUpDownExtender ID="NumericUpDownExtender1" TargetControlID="TextBox1" Width="150"    runat="server">
            </cc1:NumericUpDownExtender>
            <cc1:NumericUpDownExtender ID="NumericUpDownExtender2" TargetControlID="TextBox2" Width="150" RefValues="January;February;March;April;May;June;July;August;September;October;November;December" runat="server">
            </cc1:NumericUpDownExtender>
            <cc1:NumericUpDownExtender ID="NumericUpDownExtender3" TargetControlID="TextBox3" Width="150" ServiceUpPath="WebService1.asmx" ServiceUpMethod="NextNumber" ServiceDownPath="WebService1.asmx" ServiceDownMethod="PreNumber" runat="server">
            </cc1:NumericUpDownExtender>
            <cc1:NumericUpDownExtender ID="NumericUpDownExtender4" TargetControlID="TextBox4" Width="150" TargetButtonUpID="ImageButton2" TargetButtonDownID="ImageButton1" runat="server">
            </cc1:NumericUpDownExtender>
    </div>
    </form>
</body>
</html>


=======webservers=====

 

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
   // [ToolboxItem(false)]
    // 若要允許使用 ASP.NET AJAX 從腳本中調用此 Web 服務,請取消對下行的註釋。
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {
               [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));
        }
    }

發佈了31 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章