zoukankan      html  css  js  c++  java
  • 一个非常实用的C#弹出对话框类(包括弹出对话框,跳转到指定页面,关闭窗口)

    using System; 
    using System.Web.UI;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;

    namespace Web.Comman.Utility
    {
    /// <summary>
    /// 弹出提示框
    /// </summary>
    public class ShowMessageInfo
    {
    /// <summary>
    /// 静态方法,实现提示信息,并跳转到相应的网页
    /// </summary>
    /// <param name="Msg">提示信息</param>
    /// <param name="GoToUrl">跳转到相应的网页的url</param>
    public static void ShowMessage(string Msg, string GoToUrl)
    {
    Page p = (Page)System.Web.HttpContext.Current.Handler;
    ClientScriptManager CSM = p.ClientScript;
    String ScriptName = "ShowMsgToUrl";
    String ScriptMsg = "alert('" + Msg + "');window.open('" + GoToUrl + "','_self')";
    Type CsType = p.GetType();
    if (!CSM.IsStartupScriptRegistered(CsType, ScriptName))
    {
    CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
    }
    }
    /// <summary>
    /// 静态方法,仅实现提示信息。
    /// </summary>
    /// <param name="Msg">错误信息提示</param>
    public static void JustShowMsg(string Msg)
    {
    Page p = (Page)System.Web.HttpContext.Current.Handler;
    ClientScriptManager CSM = p.ClientScript;
    String ScriptName = "JustShowMsg";
    String ScriptMsg = "alert('" + Msg + "');";
    Type CsType = p.GetType();
    if (!CSM.IsStartupScriptRegistered(CsType, ScriptName))
    {
    CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
    }
    }
    /// <summary>
    /// 跳转到指定的url
    /// </summary>
    /// <param name="url">需要跳转的url地址</param>
    public static void GotoUrl(string url)
    {
    Page p = (Page)System.Web.HttpContext.Current.Handler;
    ClientScriptManager CSM = p.ClientScript;
    String ScriptName = "ToUrl";
    String ScriptMsg = "top.location.href='" + url + "'";
    Type CsType = p.GetType();
    CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
    }
    /// <summary>
    /// 先提示信息,然后关闭窗口
    /// </summary>
    /// <param name="Msg"></param>
    public static void ShowMsgThenCloseWindow(String Msg)
    {
    Page p = (Page)System.Web.HttpContext.Current.Handler;
    ClientScriptManager CSM = p.ClientScript;
    String ScriptName = "close";
    String ScriptMsg = "alert('" + Msg + "');window.opener = null;window.open('','_self');window.close();";
    Type CsType = p.GetType();
    if (!CSM.IsStartupScriptRegistered(CsType, ScriptName))
    {
    CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
    }
    }
    /// <summary>
    /// 关闭窗口
    /// </summary>
    public static void CloseWindow()
    {
    Page p = (Page)System.Web.HttpContext.Current.Handler;
    ClientScriptManager CSM = p.ClientScript;
    String ScriptName = "close";
    String ScriptMsg = "window.opener = null;window.open('','_self');window.close();";
    Type CsType = p.GetType();
    }
    }
    }
  • 相关阅读:
    Java多线程系列--“JUC锁”03之 公平锁(一)
    Java多线程系列--“JUC锁”02之 互斥锁ReentrantLock
    Java多线程系列--“JUC锁”01之 框架
    BIO,NIO,AIO
    Java多线程系列--“JUC线程池”06之 Callable和Future
    Java多线程系列--“JUC线程池”05之 线程池原理(四)
    Java多线程系列--“JUC线程池”04之 线程池原理(三)
    Java多线程系列--“JUC线程池”03之 线程池原理(二)
    Java多线程系列--“JUC线程池”02之 线程池原理(一)
    Java多线程系列--“JUC线程池”01之 线程池架构
  • 原文地址:https://www.cnblogs.com/jason009/p/2377944.html
Copyright © 2011-2022 走看看