后台弹出操作成功,失败信息
1 /// <summary> 2 /// 弹出信息,并跳转指定页面。 3 /// </summary> 4 public static void AlertAndRedirect(string message, string toURL) 5 { 6 string js = "<script language=javascript>alert(‘{0}‘);window.location.replace(‘{1}‘)</script>"; 7 HttpContext.Current.Response.Write(string.Format(js, message, toURL)); 8 HttpContext.Current.Response.End(); 9 }
1 /// <summary> 2 /// 弹出信息,并返回历史页面 3 /// </summary> 4 public static void AlertAndGoHistory(string message, int value) 5 { 6 string js = @"<Script language=‘JavaScript‘>alert(‘{0}‘);history.go({1});</Script>"; 7 HttpContext.Current.Response.Write(string.Format(js, message, value)); 8 HttpContext.Current.Response.End(); 9 }
1 /// <summary> 2 /// 直接跳转到指定的页面 3 /// </summary> 4 public static void Redirect(string toUrl) 5 { 6 string js = @"<script language=javascript>window.location.replace(‘{0}‘)</script>"; 7 HttpContext.Current.Response.Write(string.Format(js, toUrl)); 8 }
1 /// <summary> 2 /// 弹出信息 并指定到父窗口 3 /// </summary> 4 public static void AlertAndParentUrl(string message, string toURL) 5 { 6 string js = "<script language=javascript>alert(‘{0}‘);window.top.location.replace(‘{1}‘)</script>"; 7 HttpContext.Current.Response.Write(string.Format(js, message, toURL)); 8 } 9 10 /// <summary> 11 /// 返回到父窗口 12 /// </summary> 13 public static void ParentRedirect(string ToUrl) 14 { 15 string js = "<script language=javascript>window.top.location.replace(‘{0}‘)</script>"; 16 HttpContext.Current.Response.Write(string.Format(js, ToUrl)); 17 } 18 19 /// <summary> 20 /// 返回历史页面 21 /// </summary> 22 public static void BackHistory(int value) 23 { 24 string js = @"<Script language=‘JavaScript‘>history.go({0});</Script>"; 25 HttpContext.Current.Response.Write(string.Format(js, value)); 26 HttpContext.Current.Response.End(); 27 } 28 29 /// <summary> 30 /// 弹出信息 31 /// </summary> 32 public static void Alert(string message) 33 { 34 string js = "<script language=javascript>alert(‘{0}‘);</script>"; 35 HttpContext.Current.Response.Write(string.Format(js, message)); 36 } 37 38 /// <summary> 39 /// 注册脚本块 40 /// </summary> 41 public static void RegisterScriptBlock(System.Web.UI.Page page, string _ScriptString) 42 { 43 page.ClientScript.RegisterStartupScript(page.GetType(), "scriptblock", "<script type=‘text/javascript‘>" + _ScriptString + "</script>"); 44 }