C#常用输出JS脚本操作类

上传人:飞*** 文档编号:40227039 上传时间:2018-05-24 格式:DOC 页数:9 大小:44.50KB
返回 下载 相关 举报
C#常用输出JS脚本操作类_第1页
第1页 / 共9页
C#常用输出JS脚本操作类_第2页
第2页 / 共9页
C#常用输出JS脚本操作类_第3页
第3页 / 共9页
C#常用输出JS脚本操作类_第4页
第4页 / 共9页
C#常用输出JS脚本操作类_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《C#常用输出JS脚本操作类》由会员分享,可在线阅读,更多相关《C#常用输出JS脚本操作类(9页珍藏版)》请在金锄头文库上搜索。

1、using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Web.UI;public class JScript #region 旧版本/ / 弹出 JavaScript 小窗口/ / 窗口信息public static void Alert(string message)#regionstring js = “alert(“ + message + “);“;HttpContext.Current.Response.Write(js);#endregion

2、/ / 弹出消息框并且转向到新的 URL/ / 消息内容/ 连接地址public static void AlertAndRedirect(string message, string toURL)#regionstring js = “alert(0);window.location.replace(1)“;HttpContext.Current.Response.Write(string.Format(js, message, toURL);#endregion/ / 回到历史页面/ / -1/1public static void GoHistory(int value)#regions

3、tring js = “history.go(0); “;HttpContext.Current.Response.Write(string.Format(js, value);#endregion/ / 关闭当前窗口/ public static void CloseWindow()#regionstring js = “parent.opener=null;window.close(); “;HttpContext.Current.Response.Write(js);HttpContext.Current.Response.End();#endregion/ / 刷新父窗口/ publi

4、c static void RefreshParent(string url)#regionstring js = “window.opener.location.href=“ + url + “;window.close();“;HttpContext.Current.Response.Write(js);#endregion/ / 刷新打开窗口/ public static void RefreshOpener()#regionstring js = “opener.location.reload();“;HttpContext.Current.Response.Write(js);#en

5、dregion/ / 打开指定大小的新窗体/ / 地址/ 宽/ 高/ 头位置/ 左位置public static void OpenWebFormSize(string url, int width, int heigth, int top, int left)#regionstring js = “window.open(“ + url + “,height=“ + heigth + “,width=“ + width + “,top=“ + top + “,left=“ + left + “,location=no,menubar=no,resizable=yes,scrollbars=y

6、es,status=yes,titlebar=no,toolbar=no,directo ries=no);“;HttpContext.Current.Response.Write(js);#endregion/ / 转向 Url 制定的页面/ / 连接地址public static void JavaScriptLocationHref(string url)#regionstring js = “window.location.replace(0);“;js = string.Format(js, url);HttpContext.Current.Response.Write(js);#e

7、ndregion/ / 打开指定大小位置的模式对话框/ / 连接地址/ 宽/ 高/ 距离上位置/ 距离左位置public static void ShowModalDialogWindow(string webFormUrl, int width, int height, int top, int left)#regionstring features = “dialogWidth:“ + width.ToString() + “px“+ “;dialogHeight:“ + height.ToString() + “px“+ “;dialogLeft:“ + left.ToString()

8、+ “px“+ “;dialogTop:“ + top.ToString() + “px“+ “;center:yes;help=no;resizable:no;status:no;scroll=yes“;ShowModalDialogWindow(webFormUrl, features);#endregion/ / 弹出模态窗口/ / / public static void ShowModalDialogWindow(string webFormUrl, string features)string js = ShowModalDialogJavascript(webFormUrl, f

9、eatures);HttpContext.Current.Response.Write(js);/ / 弹出模态窗口/ / / / public static string ShowModalDialogJavascript(string webFormUrl, string features)#regionstring js = “ showModalDialog(“ + webFormUrl + “,“ + features + “);“;return js;#endregion#endregion#region 新版本/ / 弹出 JavaScript 小窗口/ / 窗口信息public

10、 static void Alert(string message, Page page)#regionstring js = “alert(“ + message + “);“;/HttpContext.Current.Response.Write(js);if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), “alert“)page.ClientScript.RegisterStartupScript(page.GetType(), “alert“, js);#endregion/ / 弹出消息框并且转向到新的 U

11、RL/ / 消息内容/ 连接地址public static void AlertAndRedirect(string message, string toURL, Page page)#regionstring js = “alert(0);window.location.replace(1)“;/HttpContext.Current.Response.Write(string.Format(js, message, toURL);if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), “AlertAndRedirec

12、t“)page.ClientScript.RegisterStartupScript(page.GetType(), “AlertAndRedirect“, string.Format(js, message, toURL);#endregion/ / 回到历史页面/ / -1/1public static void GoHistory(int value, Page page)#regionstring js = “history.go(0); “;/HttpContext.Current.Response.Write(string.Format(js, value);if (!page.C

13、lientScript.IsStartupScriptRegistered(page.GetType(), “GoHistory“)page.ClientScript.RegisterStartupScript(page.GetType(), “GoHistory“, string.Format(js, value);#endregion/ / / / 关闭当前窗口/ / / public static void CloseWindow()/ / #region/ string js = “/ parent.opener=null;window.close(); / “;/ HttpConte

14、xt.Current.Response.Write(js);/ HttpContext.Current.Response.End();/ #endregion/ / / 刷新父窗口/ public static void RefreshParent(string url, Page page)#regionstring js = “window.opener.location.href=“ + url + “;window.close();“;/HttpContext.Current.Response.Write(js);if (!page.ClientScript.IsStartupScri

15、ptRegistered(page.GetType(), “RefreshParent“)page.ClientScript.RegisterStartupScript(page.GetType(), “RefreshParent“, js);#endregion/ / 刷新打开窗口/ public static void RefreshOpener(Page page)#regionstring js = “opener.location.reload();“;/HttpContext.Current.Response.Write(js);if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), “RefreshOpe

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号