ClientScript.RegisterStartupScript()「建议收藏」

ClientScript.RegisterStartupScript()「建议收藏」一些客户端脚本usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls…

大家好,又见面了,我是你们的朋友全栈君。

一些客户端脚本

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace MyBlog.WEB
{

    public class PageBase : System.Web.UI.Page
    {

        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name=”sInputString”>需要加密的字符串</param>
        /// <returns>加密后字符串</returns>
        public static string HashString(string sInputString)
        {

            return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sInputString, “MD5”);
        }

        /// <summary>
        /// MessageBox提示框
        /// </summary>
        /// <param name=”Message”>提示信息</param>
        public void MsgBox(string Message)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>alert(‘” + Message + “‘);</script>”);
            return;
        }

        /// <summary>
        /// MessageBox提示并转向新页面
        /// </summary>
        /// <param name=”Message”>提示信息</param>
        /// <param name=”URL”>跳转的路径</param>
        public void MsgBox(string Message, string URL)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>alert(‘” + Message + “‘);window.location='” + URL + “‘;</script>”);
            return;
        }
        /// <summary>
        /// 弹出新窗口
        /// </summary>
        /// <param name=”pagePath”>页面路径</param>
        /// <param name=”winName”>新窗口名称</param>
        /// <param name=”winWidth”>新窗口宽度</param>
        /// <param name=”winHeight”>新窗口高度</param>
        public void openNewWin(string pagePath, string winName, int winWidth, int winHeight)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>window.open(‘” + pagePath + “‘,'” + winName + “‘,’toolbar=no,menubar=no,titlebar=no,directories=no,resizable=no,scroll=yes,status=no,fullscreen=no,center=yes,width=” + winWidth + “,height=” + winHeight + “‘);</script>”);
            return;
        }

        /// <summary>
        /// 弹出模态窗口
        /// </summary>
        /// <param name=”pagePath”>页面路径</param>
        /// <param name=”winWidth”>窗口宽度</param>
        /// <param name=”winHeight”>窗口高度</param>
        public void openModelWin(string pagePath, int winWidth, int winHeight)
        {

            string temp;
            temp = @”<script language=’javascript’>”;
            temp += (@”   var sPath ='” + pagePath + “‘;”);
            temp += (@”         strFeatures =’dialogWidth=” + winWidth + “px;dialogHeight=” + winHeight + “px;center=yes;scroll=no;help=no;status: No’;”);
            temp += (@”         var returnvalue = window.showModalDialog(sPath,’brower’,strFeatures);”);
            temp += (@”</script>”);

            ClientScript.RegisterStartupScript(this.GetType(), “message”, temp);
        }

        /// <summary>
        /// 弹出控制父窗口的模态窗口
        /// </summary>
        /// <param name=”pagePath”>页面路径</param>
        /// <param name=”winWidth”>窗口宽度</param>
        /// <param name=”winHeight”>窗口高度</param>
        /// <param name=”frameshref”>控制父窗口路径</param>
        public void openModelWin(string pagepath, int width, int height, string frameshref)
        {

            string temp = @”<script language=’javascript’>”;
            temp += (@”   var sPath ='” + pagepath + “‘;”);
            temp += (@”         strFeatures =’dialogWidth=” + width + “px;dialogHeight=” + height + “px;center=yes;scroll=no;help=no;status=no’;”);
            temp += (@”         var returnvalue = window.showModalDialog(sPath,’brower’,strFeatures);”);
            temp += (@”         window.location.href = ‘” + frameshref + “‘;”);
            temp += (@”</script>”);

            ClientScript.RegisterStartupScript(this.GetType(), “message”, temp);
        }

        /// <summary>
        /// 关闭本窗口
        /// </summary>
        public void CloseWin()
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>window.opener=null;window.close();</script>”);
            return;
        }

        /// <summary>
        /// 弹出提示信息,并关闭本窗口
        /// <param name=”Words”>弹出提示信息内容</param>
        /// </summary>
        public void CloseWin(string Words)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>alert(‘”+Words+”‘);window.opener=null;window.close();</script>”);
            return;
        }

        /// <summary>
        /// 关闭本窗口并,重新加载父窗口.
        /// </summary>
        /// <param name=”URL”>父窗口要加载的URL</param>
        public void reLoadParentAndClose(string URL)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>window.opener.location='” + URL + “‘;window.close();</script>”);
            return;
        }

        /// <summary>
        /// 显示提示信息,关闭本窗口并,重新加载父窗口.
        /// </summary>
        /// <param name=”Words”>提示消息内容</param>
        /// <param name=”URL”>父窗口要加载的URL</param>
        public void ShowWords_reLoadParentAndClose(string Words,string URL)
        {

            ClientScript.RegisterStartupScript(this.GetType(), “”, “<script type=’text/javascript’>alert(‘” + Words
+ “‘); window.opener.location='” + URL + “‘;window.close();</script>”);
            return;
        }

        /// <summary>
        /// 获取客户端IP
        /// </summary>
        /// <returns></returns>
        public string GetClientIP()
        {

            string result = HttpContext.Current.Request.ServerVariables[“HTTP_X_FORWARDED_FOR”];
            if (null == result || result == String.Empty)
            {

                result = HttpContext.Current.Request.ServerVariables[“REMOTE_ADDR”];
            }

            if (null == result || result == String.Empty)
            {

                result = HttpContext.Current.Request.UserHostAddress;
            }
            return result;
        }

/// <summary>
        /// 获取Session值
        /// </summary>
        /// <param name=”SessionID”>要获取的Session值</param>
        /// <returns></returns>
        public string GetSession(string SessionID)
        {

            string restr = “unkown”;
            try
            {

                restr = Session[SessionID].ToString();
            }
            catch
            {

            }
            if (restr == “unkown” && restr == null && restr == “”)
            {

                Response.Redirect(“/Error.aspx?Type=NoPopedom”);
            }
            return restr;
        }

        /// <summary>
        /// 写Cookie
        /// </summary>
        /// <param name=”CookiesName”>Cookie集名称</param>
        /// <param name=”name”>Cookie名</param>
        /// <param name=”Value”>值</param>
        public void WritCookie(string CookiesName, string name, string Value)
        {

            HttpCookie cookie = new HttpCookie(CookiesName);
            cookie.Values.Add(name, Value);
            Response.AppendCookie(cookie);
        }

        /// <summary>
        /// 获取Cookie
        /// </summary>
        /// <param name=”CookiesName”>Cookie集名称</param>
        /// <param name=”name”>Cookie名</param>
        /// <param name=”Value”>值</param>
        public string GetCookie(string CookiesName, string name)
        {

            string value = string.Empty;
            try
            {

                HttpCookie cookie = Request.Cookies[CookiesName];
                value = cookie.Values[name];
            }
            catch
            {

                Response.Redirect(“/Error.aspx?Type=GetCookie”);
            }
            return value;
        }
    }
}

转载于:https://www.cnblogs.com/softwareking/archive/2011/03/19/1988570.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/162301.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • labelme图像标注_ai标注工具

    labelme图像标注_ai标注工具参考:https://blog.csdn.net/u011574296/article/details/79740633在做目标检测任务时,需要用到labelImg进行画框标注,在之前的文章中已经介绍过该工具的使用方法。然而如果是做语义分割的任务时,就不能只是标注框里,需要用另外一种工具labelme进行标注,本文对该工具的安装使用方法进行介绍。官方教程:https://github.co…

  • 如何解决“请在微信客户端打开链接”

    如何解决“请在微信客户端打开链接”如题,这个问题确实很苦恼,写下这篇博客记录下自己的问题。

  • 删除链表倒数第n个节点_单向链表删除倒数第n节点

    删除链表倒数第n个节点_单向链表删除倒数第n节点原题链接给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。进阶:你能尝试使用一趟扫描实现吗?示例 1:输入:head = [1,2,3,4,5], n = 2输出:[1,2,3,5]示例 2:输入:head = [1], n = 1输出:[]示例 3:输入:head = [1,2], n = 1输出:[1]提示:链表中结点的数目为 sz1 <= sz <= 300 <= Node.val <= 1001 <= n <= s

  • pycharm环境变量配置Anaconda_phpstorm怎么配置环境

    pycharm环境变量配置Anaconda_phpstorm怎么配置环境在Windows7系统中,安装并配置Spyder与Pycharm的Anaconda环境Python解释器方法

  • 时序数据库介绍_时序数据库公司

    时序数据库介绍_时序数据库公司首先,什么是时序数据? ​ 简单来说,时序数据就是按照时间维度索引的数据,比如车辆轨迹数据,传感器温度数据。随着物联网时代的到来,时序数据的数据量呈井喷式爆发,针对于这一数据细分的优化存储显得越来越重要。01什么是InfluxDBInfluxDB是一个开源的、高性能的时序型数据库,在时序型数据库DB-EnginesRanking上排名第一。在介绍InfluxDB之前,先来介绍下时序数据。按照时间顺序记录系统、设备状态变化的数据被称为时序数据(TimeSeriesData),如.

  • 关于华为任正非裁员事件

    关于华为任正非裁员事件最近,关于“华为大力清洗34岁+的老员工”的新闻一直在发酵。消息是从华为的心声论坛传出,具体内容是华为职工反映,中国区开始集中清理34岁以上的的交付工程维护人员。而研发开始集中清退40岁以上的老员工,主要针对程序员。一时间,“华为无情”批评四起。  无风不起浪  华为公关对消息予以否定。但这件事明显已经掀起了不小的波澜。  创始人任正非近期在一份讲话中侧面回应了

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号