后台部分
- public partial class main : Page, ICallbackEventHandler//回调函数继承
- {
- if (!IsPostBack)
- {
- //.net异步请求 chgQty('参数','');
- //chgResult(ret)返回值 该方法需要手动创建ret为异步返回值
- string cbRef = Page.ClientScript.GetCallbackEventReference(this, "arg1", "chgResult", "context");
- string cbScript = "";
- cbScript = "function chgQty(arg1,context){" + cbRef + "};";
- Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "chgQty", cbScript, true);
- }
- }
-
- #region ICallbackEventHandler 异步请求成员
- string AreturnStr = "";
- public string GetCallbackResult()
- {
- return AreturnStr;//返回的参数
- }
-
- public void RaiseCallbackEvent(string eventArgument)//接收的参数
- {
- //给 AreturnStr 赋值就可以返回
- }
- #endregion
复制代码
前台js调用
- //自己定义接收方法 与后台对应
- //前台js 调用 chgQty("参数", ""); 访问后台
- function chgResult(RetStr) {
- //RetStr 为后台返回值
- }
复制代码
|
|