var prm = Sys.WebForms.PageRequestManager.getInstance();
alert(prm.get_isInAsyncPostBack()); //判断是否为异步提交
一.Ajax类
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script language="javascript" type="text/javascript">
Type.registerNamespace("AspNetAjaxOverView"); //注册命名空间
//写一个类,=号后为构造方法
AspNetAjaxOverView.Person = function(firstName, lastName)
把这个类注册到命名空间
AspNetAjaxOverView.Person.registerClass("AspNetAjaxOverView.Person");
//定义子类
AspNetAjaxOverView.Employee = function(firstName, lastName, title)
继承父类的构造方法
AspNetAjaxOverView.Employee.initializeBase(this, [firstName, lastName]);
this._title = title;
}
AspNetAjaxOverView.Employee.prototype =
注册时第二个参数表明为继承父类
AspNetAjaxOverView.Employee.registerClass("AspNetAjaxOverView.Employee", AspNetAjaxOverView.Person);
</script>
二.异步通讯类
1.服务器端定义一个C#类
public class Employee
{
private string _FirstName;
private string _LastName;
private string _Title;
public Employee() { }
public Employee(string firstName, string lastName, string title)
public string FirstName
public string LastName
public string Title
}
2.服务器端接收请求的GetEmployee.ashx
![]()
}
3.客户端调用这个类
![]()
>
三.客户端调用Webservice
1.服务器端Webservice
namespace AspNetAjaxOverview
}
2.客户端调用
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<!--为ScriptManager指定WebService服务器端程序,会自动生成客户端代理-->
<asp:ServiceReference Path="EmployeeService.asmx" />
</Services>
</asp:ScriptManager>

<script language="javascript" type="text/javascript">
function showEmployee(firstName, lastName, title)
>
相关文章:
-
2021-09-27
-
2021-08-06
-
2021-08-12
-
2022-12-23
-
2021-11-20
-
2021-11-23
-
2021-06-28
-
2022-01-01