A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© sunrise2 高级黑马   /  2014-8-11 09:31  /  750 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


后台部分
  1. public partial class main : Page, ICallbackEventHandler//回调函数继承
  2.     {
  3. if (!IsPostBack)
  4.             {
  5.                 //.net异步请求  chgQty('参数','');
  6.                 //chgResult(ret)返回值  该方法需要手动创建ret为异步返回值
  7.                 string cbRef = Page.ClientScript.GetCallbackEventReference(this, "arg1", "chgResult", "context");
  8.                 string cbScript = "";
  9.                 cbScript = "function chgQty(arg1,context){" + cbRef + "};";
  10.                 Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "chgQty", cbScript, true);
  11.             }
  12. }

  13. #region ICallbackEventHandler 异步请求成员
  14.         string AreturnStr = "";
  15.         public string GetCallbackResult()
  16.         {
  17.             return AreturnStr;//返回的参数
  18.         }

  19.         public void RaiseCallbackEvent(string eventArgument)//接收的参数
  20.         {
  21.          //给 AreturnStr 赋值就可以返回
  22.         }
  23.         #endregion
复制代码

前台js调用
  1. //自己定义接收方法 与后台对应   
  2. //前台js 调用  chgQty("参数", ""); 访问后台
  3. function chgResult(RetStr) {
  4. //RetStr 为后台返回值
  5. }
复制代码


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马