PageMethods方法的一点研究

PageMethods方法的一点研究

 

PageMethods.FunctionName(Paramter1,Parameter2,...,SuccessMethod, FailedMethod, userContext);
其中,前面Paramter1,Parameter2,...,表示的是FunctionName的参数,类型是Object或Array;
SuccessMethod是需要使用后台返回结果的Js方法,
FailedMethod是当后台的csFunctionName方法发生异常情况下的执行的Js方法(容错处理方法),
userContext是可以传递给SuccessMethod方法,或是FailedMethod方法的任意内容。

 
大体结构如下:

         后台CS方法

         [System.Web.Services.WebMethod]
         [System.Web.Script.Services.ScriptMethod]
         public static string[] csFunctionName(string para1,string[] para2,int para3)
         {
             //...        

         }
        
         //----------------------------------------------------------------------

         前台页面Javascript方法
         //成功回调方法
         function getFunctionName(rtn)
         {
             //使用csFunctionName方法返回的 string[]中的值
         }
        //失败回调方法
         function errorFunction(error)
         {
            //出错处理方法
         }

        //对外接口方法

         function JsFunctionName(para) 
         {
                //debugger;
                var str = para;
                var arr = new Array('str1','str2','str3');
                //PageMethods.FunctionName(str,arr,3, getFunctionName,errorFunction,context);
                PageMethods.FunctionName(str,arr,3, getFunctionName,errorFunction);
         }

       

 

       其实这三个方法合起来,就相当于一个前台方法,对外接口方法为:JsFunctionName(para) 。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值