/// <summary> /// 显示消息提示对话框,并进行页面跳转 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">提示信息</param> /// <param name="url">跳转的目标URL</param> public static void ShowAndRedirect(System.Web.UI.Page page,string msg,string url) { //Response.Write("<script>alert('帐户审核通过!现在去为企业充值。');window.location=\"" + pageurl + "\"</script>"); page.ClientScript.RegisterStartupScript(page.GetType(), UnionID().ToString(), "<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>"); }
/// <summary> /// 显示消息提示对话框 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">提示信息</param> public static void Show(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');</script>"); // UpdatePanel采用如下方式弹出对话框 //System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "javascript", "alert('您已经投过票!');", true); }
/// <summary> /// ��ʾ��Ϣ��ʾ�Ի�������ҳ����ת /// </summary> /// <param name="page">��ǰҳ��ָ�룬һ��Ϊthis</param> /// <param name="msg">��ʾ��Ϣ</param> /// <param name="url">��ת��Ŀ��URL</param> public static void ShowAndRedirects(System.Web.UI.Page page, string msg, string url) { StringBuilder Builder = new StringBuilder(); Builder.Append("<script language='javascript' defer>"); Builder.AppendFormat("alert('{0}');", msg); Builder.AppendFormat("top.location.href='{0}'", url); Builder.Append("</script>"); page.ClientScript.RegisterStartupScript(page.GetType(), "message", Builder.ToString()); }
/// <summary> /// 显示消息提示对话框 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">提示信息</param> public static void Show(System.Web.UI.Page page, messageString msg) { string str = ""; switch (msg) { case messageString.addsuccess: str = "添加成功"; break; case messageString.addlose: str = "添加失败"; break; case messageString.updatesuccess: str = "更新成功"; break; case messageString.updatelose: str = "更新失败"; break; } page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + str + "');</script>"); }
/// <summary> /// 提示框,针对easyUi /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="script">输出脚本</param> /// <param name="script">提示类型</param> /// <param name="Fun">回调函数</param> public static void Show(System.Web.UI.Page page, string msg, InfoType it,string Fun) { page.ClientScript.RegisterStartupScript(page.GetType(), UnionID().ToString(), "<script language='javascript' defer>using('messager',function(){$.messager.alert('系统提示','" + msg.Replace("'", "\"").Replace("\n", "").Replace("\r", "") + "。','" + it.ToString() + "'," + Fun + ")});</script>"); }
/// <summary> /// 输出自定义脚本信息 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="script">输出脚本</param> public static void ResponseScript(System.Web.UI.Page page,string script) { page.ClientScript.RegisterStartupScript(page.GetType(), UnionID().ToString(), "<script language='javascript' defer>" + script + "</script>"); }
/// <summary> /// 显示消息提示对话框 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">提示信息</param> public static void Show(System.Web.UI.Page page,string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), UnionID().ToString(), "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>"); }
/// <summary> /// 自定义脚本信息 /// </summary> /// <param name="page"></param> /// <param name="msg"></param> public static void AlertLocation(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>" + msg + "</script>"); }
/// <summary> /// ��ʾ��Ϣ��ʾ�Ի�������ҳ����ת /// </summary> /// <param name="page">��ǰҳ��ָ�룬һ��Ϊthis</param> /// <param name="msg">��ʾ��Ϣ</param> /// <param name="url">��ת��Ŀ��URL</param> public static void ShowAndRedirect(System.Web.UI.Page page,string msg,string url) { //Response.Write("<script>alert('�ʻ����ͨ��������ȥΪ��ҵ��ֵ��');window.location=\"" + pageurl + "\"</script>"); page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>"); }
/// <summary> /// 注册脚本块 /// </summary> public static void RegisterScriptBlock(System.Web.UI.Page page, string _ScriptString) { page.ClientScript.RegisterStartupScript(page.GetType(), "scriptblock", "<script type='text/javascript'>" + _ScriptString + "</script>"); }
/// <summary> /// 显示操作失败的提示信息 /// </summary> /// <param name="page"></param> /// <param name="msg"></param> public static void ShowFailTip(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>ShowFailTip('" + msg + "');</script>"); }
/// <summary> /// 显示消息提示对话框,并返回原页面 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">提示信息</param> public static void ShowAndBack(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');history.back();</script>"); }
/// <summary> /// 显示操作成功提示信息 /// </summary> /// <param name="page"></param> /// <param name="msg"></param> public static void ShowSuccessTip(System.Web.UI.Page page, string msg, string url) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>ShowSuccessTip('" + msg + "');function jump(count){window.setTimeout(function(){count--;if(count>0){jump(count)}else{window.location.href=\"" + url + "\"}},1000)}jump(3);</script>"); }
/// <summary> /// 运行客户端JavaScript脚本 /// </summary> /// <param name="ctrl">放置脚本的控件</param> /// <param name="code">JavaScript代码</param> /// <param name="mode">执行模式</param> public static void RunScript(System.Web.UI.Control ctrl, string code,ScriptMode mode) { if (mode == ScriptMode.BeforeLoad) { ctrl.Page.ClientScript.RegisterClientScriptBlock(ctrl.GetType(), "jsBlock", code, true); } else if (mode == ScriptMode.AfterLoad) { System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericControl(); hgc.TagName = "div"; hgc.InnerHtml = "<script type=\"text/javascript\">"; hgc.InnerHtml += code; hgc.InnerHtml += "</script>"; ctrl.Controls.Add(hgc); } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(ctrl, ctrl.GetType(), "jsBlock", code, true); } }