日期:2009-12-05 浏览次数:20388 次
[C#] <%@ Page Language="C#" %> <%@ Import Namespace="System.Net" %> <html> <script language="C#" runat="server"> void EnterBtn_Click(Object Src, EventArgs E) { MyMath.Math math = new MyMath.Math(); // Call to Add XML Web service method asynchronously // and then wait for it to complete. IAsyncResult result = math.BeginAdd(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text), null, null); // Wait for asynchronous call to complete. result.AsyncWaitHandle.WaitOne(); // Complete the asynchronous call to Add XML Web service method. float total = math.EndAdd(result); // Display 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 then 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" %> <html> <script language="VB" runat="server"> Sub EnterBtn_Click(Src As Object, E As EventArgs) Dim math As New MyMath.Math() ' Call to Add XML Web service method asynchronously ' and then wait for it to complete. Dim result As IAsyncResult = _ math.BeginAdd(Convert.ToInt32(Num1.Text), _ Convert.ToInt32(Num2.Text), _ Nothing, _ Nothing) ' Wait for asynchronous call to complete. result.AsyncWaitHandle.WaitOne() ' Complete the asynchronous call to Add XML Web service method. Dim addtotal As Single = math.EndAdd(result) ' Display 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 then 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> </ht
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|