使用AjaxPro.dll文件实现简单Ajax应用

web开发中,经常会用到简单Ajax技术,本文将介绍一种简单Ajax使用方法。

1.         资源文件

我们将使用一开源的Ajax组件Ajaxpro.dlldll文件下载链接如下:

/Files/zky123/AjaxPro.zip

2.         使用方法

a)         web.config配置文件中添加<httpHandlers>节点。在web.config<system.web>节点中加入如下的代码即可:

<system.web>

            <httpHandlers>

                <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>

            </httpHandlers>

        </system.web>

b)         在页面的Page_Load方法中注册脚本。

protected void Page_Load(object sender, EventArgs e)

        {

AjaxPro.Utility.RegisterTypeForAjax(typeof(注册类的完整名称));

            ......

        }

c)         编写注册类要使用Ajax的方法。可以返回简单对象,也可以返回自定义对象。

[AjaxPro.AjaxMethod]

 public IList<JobInfo> GetAllJobsByCondition(string deptNo)

 {

     IList<JobInfo> result = InterviewManager.Instance.GetAllJobsByDeptNo(deptNo);

     return result;

 }

d)         用脚本调用Ajax方法。返回值为object对象,需要取其value属性才是真正的返回值。

var result =注册类的完整名称. GetAllJobsByCondition ("para");

if(result.value != null) {...... }

3.         官方网址

更多请参考官方网址:http://www.ajaxpro.info/

 

posted @ 2009-06-09 23:01  地之雾  阅读(238)  评论(0编辑  收藏  举报