1首先在web.config中添加支持

  <httpHandlers>

 <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory,   Ajax"/><!--ajax.dll -->

  <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/><!--ajaxPro.dll-->

</httpHandlers>

2下载ajax.dll  或ajaxpro.dll

3在页面类初始加载注册拥有ajax方法的类

例:   Ajax.Utility.RegisterTypeForAjax(typeof(AjaxClass));//AjaxClass是自己写的一个类

 

 

  [Ajax.AjaxMethod()]
    public static string GetTreeStr()
    {
        IList<Department> ParentNodes = new DepartmentService().GetParentNode();
        string str="“;
        if (ParentNodes != null && ParentNodes.Count > 0)
        {
            for (int i = 0; i < ParentNodes.Count; i++)
            {
                str+="d.add("+((i + 1) + ",0,'" + ParentNodes[i].Name + "'," + "' ');");
            }

        }
        return str;


    }

 

posted on 2009-03-23 13:03  冷傲残痕  阅读(886)  评论(0编辑  收藏  举报