首页 > 其他 > 详细

ClientScript.GetCallbackEventReference 调用服务端函数

时间:2016-02-02 09:45:12      阅读:203      评论:0      收藏:0      [点我收藏+]

客户端编写

<%= ClientScript.GetCallbackEventReference(this, "arg", "func", "context")%>

其中func参数为回调函数,context为上下文也可以指定为null,this参数为本页面,arg参数为要传给服务端函数的参数

function func(result,context)  // result为服务端返回数据,context为页面接收控件(根据自己数据用途,可有可无)

{context.innerHtml = result}

服务端编写

服务端处理客户端传递数据的函数 RaiseCallbackEvent(string EventArgument)//切记函数名是约定好的,不可更改

string result = "";

public void RaiseCallbackEvent(string EventArgument)
{
    result= EventArgument;
}

服务端返回客户端数据的函数 GetCallbackResult()// 函数名称是约定好的,不可更改

public string GetCallbackResult()

{

  return result+"hello";

}

 

ClientScript.GetCallbackEventReference 调用服务端函数

原文:http://www.cnblogs.com/zhftyy/p/5176738.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!