zoukankan      html  css  js  c++  java
  • 一段很有用的Alert代码

    //显示JavaScript的Alert信息

    public static void ShowMsg(Page thisPage, string AlertMessage)

    {

    Literal txtMsg = new Literal();

    txtMsg.Text = "<script id='theMessage'>alert(\"" + AlertMessage + "\");</script>" + "<BR/>";

    thisPage.Controls.Add(txtMsg);

    }

     

    /// <summary>

    /// 显示JavaScript的Alert信息,加跳转

    /// </summary>

    /// <param name="thisPage"></param>

    /// <param name="AlertMessage"></param>

    public static void ShowMsg(Page thisPage,string AlertMessage, string URL)

    {

    Literal txtMsg = new Literal();

     

    //为空则跳转到当前页面

    URL = URL == string.Empty ? GetRequest.GetUrl() : GetRequest.GetHostUrl() +"/"+ URL;

    txtMsg.Text = "<script id='theMessage'>alert('" + AlertMessage + "');";

    txtMsg.Text += "window.location='" + URL + "';</script></script>";

    thisPage.Controls.Add(txtMsg);

    }

     

    /// <summary>

    /// 获得当前完整Url地址

    /// </summary>

    /// <returns>当前完整Url地址</returns>

    public static string GetUrl()

    {

    return HttpContext.Current.Request.Url.ToString();

    }

     

    /// <summary>

    /// 得到当前URL,带端口

    /// </summary>

    /// <returns></returns>

    public static string GetHostUrl()

    {

    HttpRequest request = System.Web.HttpContext.Current.Request;

    if (!request.Url.IsDefaultPort)

    {

    return "http://" + string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString());

    }

    return "http://" + request.Url.Host;

    }    

  • 相关阅读:
    单机部署Fastfds+nginx
    day_ha配置文件
    day_1_登录接口

    表(list)
    Java基础01 ------ 从HelloWorld到面向对象
    测试V模型
    360极速模式和兼容模式区别
    初识VBS
    Bug描述规范
  • 原文地址:https://www.cnblogs.com/francis67/p/927079.html
Copyright © 2011-2022 走看看