AjaxPro.2.dll使用方法简介

AjaxPro是ASP.NET平台上著名的AJAX框架,全名叫Ajax.NET Professional

下面介绍一下它的用法:

1.首先必须添加AjaxPro.2.dll的引用。

2.在Web.config中system.web中进行如下配置:

3.注册页面以及构造服务端方法。

AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxProTest));

这句话是注册页面调用类名,用于在前台页面生成如下两行代码

<script type="text/javascript" src="/ch33/ajaxpro/core.ashx"></script>

<script type="text/javascript" src="/ch33/ajaxpro/ch33.Verify,ch33.ashx"></script>

4.前台页面JS直接调用

 

5.最终效果

 

这样,一个简单的前台JS调用后台服务器方法的实现就完成了,其中返回数据的序列化和反序列化AjaxPro都已经帮我们封装好了,如方法返回一个实体类,则稍作更改如下:

var person = AjaxProDemo.AjaxProTest.GetPersonByName().value;
$(
function () {
alert(person.Age);
//Person实体类中的Age属性。
alert(person.Gender);//Person实体类中的Gender属性。
});
posted @ 2014-02-27 09:26  汪强胜  Views(186)  Comments(0Edit  收藏  举报