js 后台异步执行

 public void AlertMsg(string msg, bool async)
        {
            string script = string.Format("alert('{0}'); ", msg);
            RegisterClientScript(script, async);

 

 public void RegisterClientScript(string script, bool async)
        {
            if (async)
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), script, true);
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), script, true);
            }
        }

 

posted @ 2015-12-04 15:54  ChineseMoonGod  阅读(219)  评论(0)    收藏  举报