asp.net 后台执行前台js方法

         #region Ajax中执行JS脚本
        /// <summary>
        /// Ajax中执行JS脚本
        /// </summary>
        /// <param name="ctrl">调用的控件</param>
        /// <param name="script">执行JS脚本</param>
        public static void AjaxScript(Control ctrl, string script)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(ctrl, ctrl.GetType(), "", script, true);
        }
        #endregion
 
 
 
调用方式:
      AjaxScript(this.Page, "tt();")   //   tt() 为前台的js方法名称;  模板页面用  this.Page     普通页面直接用 Page 就ok

猜你喜欢

转载自www.cnblogs.com/zengxh/p/12390589.html