• 一段很有用的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;

    }    

  • 相关阅读:
    typescript 深层次对象内层(N)转外层(N),支持多层级递归转换,多应用于多语言数据结构转换
    js 柯里化、深拷贝、浅拷贝
    js IntersectionObserver api
    javascript-state-machine
    NodeJs的CommonJS模块规范
    js 动画
    【THUPC 2018】赛艇
    【CF528D】Fuzzy Search
    【UR #6】懒癌
    【HNOI 2019】JOJO
  • 原文地址:https://www.cnblogs.com/francis67/p/927079.html
Copyright © 2020-2023  润新知