扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:李娟编译 来源:天极网 2007年11月7日
关键字: Windows
<%@ OutputCache Duration="60" %> |
[C#] <%@ Page Language="C#" %> <%@ Import Namespace="System.Net" %> <%@ OutputCache Duration="60" VaryByParam="none" %> <html> <script language="C#" runat="server"> void EnterBtn_Click(Object Src, EventArgs e) { MyMath.Math math = new MyMath.Math(); // Call the XML Web service. float total = math.Add(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text)); // Display the results in a Label control. Total.Text = "Total: " + total.ToString(); } </script> <body> <form action="MathClient.aspx" runat=server> <font face="Verdana"> Enter the two numbers you want to add and press the Total button. <p> Number 1: <asp:textbox id="Num1" runat=server/> + Number 2: <asp:textbox id="Num2" runat=server/> = <asp:button id="Total_Button" text="Total" OnClick="EnterBtn_Click" runat=server/> <p> <asp:label id="Total" runat=server/> </font> </form> </body> </html> [Visual Basic] <%@ Page Language="VB" %> <%@ Import Namespace="System.Net" %> <%@ OutputCache Duration="60" VaryByParam="none" %> <html> <script language="VB" runat="server"> Sub EnterBtn_Click(Src As Object, e As EventArgs) Dim math As New MyMath.Math() ' Call the XML Web service. Dim addtotal As Single = math.Add(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text)) ' Display the results in a Label control. Total.Text = "Total: " & addtotal.ToString() End Sub </script> <body> <form action="MathClient.aspx" runat=server> <font face="Verdana"> Enter the two numbers you want to add and press the Total button. <p> Number 1: <asp:textbox id="Num1" runat=server/> + Number 2: <asp:textbox id="Num2" runat=server/> = <asp:button id="Total_Button" text="Total" OnClick="EnterBtn_Click" runat=server/> <p> <asp:label id="Total" runat=server/> </font> </form> </body> </html> |
[C#] <%@ WebService Language="C#" Class="MathService" %> using System; using System.Web.Services; public class MathService : WebService { [WebMethod(CacheDuration=60)] public float Add(float a, float b) { return a + b; } [WebMethod(CacheDuration=60)] public float Subtract(float a, float b) { return a - b; } [WebMethod(CacheDuration=60)] public float Multiply(float a, float b) { return a * b; } [WebMethod(CacheDuration=60)] public float Divide(float a, float b) { if (b==0) return -1; return a / b; } } [Visual Basic] <%@ WebService Language="VB" Class="MathService" %> Imports System Imports System.Web.Services Public Class MathService Inherits WebService <WebMethod(CacheDuration := 60)> _ Public Function Add(a As Single, b As Single) As Single Return a + b End Function <WebMethod(CacheDuration := 60)> _ Public Function Subtract(a As Single, b As Single) As Single Return a - b End Function <WebMethod(CacheDuration := 60)> _ Public Function Multiply(a As Single, b As Single) As Single Return a * b End Function <WebMethod(CacheDuration := 60)> _ Public Function Divide(a As Single, b As Single) As Single If b = 0 Then Return - 1 End If Return a / b End Function End Class |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者