js 后台弹窗

后台弹出操作成功,失败信息

  

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         }

 

转载于:https://www.cnblogs.com/dandanwozhishidan/p/3565966.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值