ASP.NET AJAX中 复杂数据类型使用简单实例
来源:互联网 发布:右下角网络连接红叉 编辑:程序博客网 时间:2024/05/22 17:07
aspx页面
<asp:ScriptManager ID="ScriptManager1" runat="server"><Services><asp:ServiceReference Path="ComplexType.asmx" /></Services></asp:ScriptManager><input type="button" value="Double Salary" onclick="doubleSalary()" /><input type="button" value="Reverse" onclick="reverse([1, 2, 3, 4, 5])" /><input type="button" value="Get Employees" onclick="getEmployees()" /><script language="javascript" type="text/javascript">function doubleSalary(){var employee = new Object();employee.FirstName = "Jeffrey";employee.LastName = "Zhao";employee.Salary = 1000;ComplexType.DoubleSalary(employee, doubleSalarySucceeded);}function doubleSalarySucceeded(result){var message = String.format("First Name: {0}\nLast Name: {1}\nFull Name: {2}\nSalary: {3}",result.FirstName,result.LastName,result.FullName,result.Salary);alert(message);}function reverse(array){ComplexType.Reverse(array, function(result){alert(result);});}function getEmployees(){ComplexType.GetEmployees(getEmployeesSucceeded);}function getEmployeesSucceeded(result){for (var key2 in result){ alert(key2 + ": " + result[key2].Salary)}}</script>
ComplexType.asmx页面
<%@ WebService Language="C#" Class="ComplexType" %>using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Collections.Generic;[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.Web.Script.Services.ScriptService]public class ComplexType : System.Web.Services.WebService {[WebMethod]public Employee DoubleSalary(Employee employee){employee.Salary *= 2;return employee; }[WebMethod]public List<int> Reverse(List<int> list){list.Reverse();return list;}[WebMethod]public IDictionary<string, Employee> GetEmployees(){Dictionary<string, Employee> result = new Dictionary<string, Employee>();Employee emp1 = new Employee();emp1.FirstName = "Jeffrey";emp1.LastName = "Zhao";emp1.Salary = 1000;result[emp1.FullName] = emp1;Employee emp2 = new Employee();emp2.FirstName = "Tom";emp2.LastName = "Chen";emp2.Salary = 2000;result[emp2.FullName] = emp2;return result;}}
Employee.cs类页面代码
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;/// <summary>/// Summary description for Employee/// </summary>public class Employee{public string FirstName;public string LastName;public int Salary;public string FullName{get{return this.FirstName + " " + this.LastName;}}}
- ASP.NET AJAX中 复杂数据类型使用简单实例
- ASP.NET AJAX中 复杂数据类型使用简单实例
- 在asp.net AJAX客户端使用复杂数据类型方法
- asp.net中ajax修改密码简单实例
- 在ASP.NET中使用无框架的Ajax实例
- 在ASP.NET中使用无框架的Ajax实例
- Ajax 复杂数据类型使用基础
- 在ASP.NET中使用AJAX的简单方法
- 在ASP.NET中使用AJAX的简单方法
- 在ASP.NET中使用AJAX的简单方法
- 在ASP.NET中使用AJAX的简单方法
- 在ASP.NET中使用AJAX的简单方法
- 在ASP.NET MVC中简单使用跨域Ajax
- ASP.NET中使用Ajax
- ASP.NET中"委托"(delegate)的使用简单实例
- asp.net中Ajax分页实例
- [ASP.NET]在ASP.NET中使用AJAX的简单方法
- ASP+AJAX简单实例
- ECMAScript 5正式发布
- asp.net ajax中的错误处理
- 郗晓勇:如何减小与“大牛”的差距
- delphi-cxgrid-cxtreelist加行序号
- android使用mina需要注意的问题
- ASP.NET AJAX中 复杂数据类型使用简单实例
- ClientAbortException,Connection reset by peer: socket write error
- GNU ARM汇编--(九)s3c2440的PWM
- 客户端代理使用细节【函数调用/回调函数的完整签名及WebService级别默认属性】
- 写在最前面
- 如何在XP机器上安装Linux虚拟机
- db2之in和exist的性能区别
- linux下 XML 的学习总结
- 12 个有效的提高编程技能的方法