- using System;
- using System.Text;
- using System.Web.UI;
-
- namespace XXXX.Common
- {
- public class Js
- {
-
-
-
-
-
-
- public static void ShowAndBack(System.Web.UI.Page page, string msg)
- {
- page.Response.Clear();
- page.Response.Write(String.Format("<script type=\"text/javascript\">alert(\"{0}\");history.back();</script>", msg));
- page.Response.End();
- }
-
-
-
-
-
-
- public static void ShowAndClose(System.Web.UI.Page page, string msg)
- {
- page.Response.Clear();
- page.Response.Write(String.Format("<script type=\"text/javascript\">alert(\"{0}\");", msg));
- page.Response.Write("try{frameElement.api.opener.$.dialog.list[\"dialogWindow\"].close();}catch(e){ }</script>");
- page.Response.End();
- }
-
-
-
-
-
-
- public static void ShowCloseRefresh(System.Web.UI.Page page, string msg)
- {
- page.Response.Clear();
- page.Response.Write(String.Format("<script type=\"text/javascript\">alert(\"{0}\");", msg));
- page.Response.Write("try{frameElement.api.opener.$.dialog.list[\"dialogWindow\"].close(); frameElement.api.opener.location.reload();}catch(e){ }</script>");
- page.Response.End();
- }
-
-
-
-
-
-
-
- public static void Show(System.Web.UI.Page page, string msg)
- {
- ClientScriptManager cs = page.ClientScript;
- cs.RegisterStartupScript(page.GetType(), "message", String.Format("<script type=\"text/javascript\">alert(\"{0}\");</script>", msg));
- }
-
-
-
-
-
-
-
- public static void Show(System.Web.UI.Page page, string msg, string url)
- {
- StringBuilder Builder = new StringBuilder();
- Builder.Append("<script type=\"text/javascript\">\r\n");
- Builder.AppendFormat("alert('{0}');", msg);
- Builder.AppendFormat("top.location.href='{0}'", url);
- Builder.Append("</script>");
- page.Response.Clear();
- page.Response.Write(Builder.ToString());
- page.Response.End();
- }
-
-
-
-
-
-
-
-
- public static void Show( System.Web.UI.Page page, string msg, string url,string target )
- {
- StringBuilder Builder = new StringBuilder();
- Builder.Append("<script type=\"text/javascript\">\r\n");
- Builder.AppendFormat("alert('{0}');\r\n", msg);
- Builder.AppendFormat(String.Format("{0}.location.href='{{0}}';\r\n", target), url);
- Builder.Append("</script>\r\n");
- page.Response.Clear();
- page.Response.Write(Builder.ToString());
- page.Response.End();
- }
-
-
-
-
-
- public static void ResponseScript(System.Web.UI.Page page, string script)
- {
- ClientScriptManager cs = page.ClientScript;
- cs.RegisterStartupScript(page.GetType(), "message", String.Format("\r\n<script type=\"text/javascript\">\r\n{0}\r\n</script>\r\n", script));
- }
-
-
-
- }
- }
转自http://blog.csdn.net/anchenyanyue/article/details/7666366