使用AjaxPro

1:后台注册

protected void Page_Load(object sender, EventArgs e)

        {

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

        }

2:后台方法家标识

        /// <summary>

        /// 查询置顶小区

        /// </summary>

        /// <returns></returns>

        [AjaxPro.AjaxMethod]

        public List<RoomByCommunity> GetTopRoom(string co_autoid)

        {

            List<RoomByCommunity> lis = new List<RoomByCommunity>();

            lis = new RoomService().GetTopRoom(co_autoid);



            return lis;

        }

3:前台方法调用

    //获取下一级Room

    function GetNextRom(RBC_AutoID) {

        $("#input_Return_SelectCommunity").show();

        var x = CRM.Page.crm.UserContronel.SelectRoomByCommunity.GetNextRoom(RBC_AutoID);

        $("#AreaList_SelectRoomByCommunity").html("")

        $(x.value).each(function(index, ele) {

            if (ele.RBC_IsLast == 1) {//最后一级

                var topcom = '<a   onClick=GetRoomAddress("' + ele.RBC_AutoID + '","' + ele.RBC_Name + '")>' + ele.RBC_Name + '</a>';

            } else {

                var topcom = '<a   onClick=GetNextRom("' + ele.RBC_AutoID + '")>' + ele.RBC_Name + '</a>';

            }

            $("#AreaList_SelectRoomByCommunity").html($("#AreaList_SelectRoomByCommunity").html() + topcom);

        });

        $("#AreaList_SelectRoomByCommunity").html($("#AreaList_SelectRoomByCommunity").html() + '<div class="clear"></div>');

    }

4:web.config修改

        <httpHandlers>

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

        </httpHandlers>

 

 

==================================

http://www.cnblogs.com/lexus/archive/2007/11/29/977281.html

你可能感兴趣的:(Ajax)