• 客户端脚本输出


    MXS&Vincene  ─╄OvЁ  &0000008 ─╄OvЁ  MXS&Vincene 

    MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好,但是绝大部分人是死在明天晚上,只有那些真正的英雄才能见到后天的太阳。

    MXS&Vincene  ─╄OvЁ:We're here to put a dent in the universe. Otherwise why else even be here? 

     

    正文>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    /// <summary>
    /// 客户端脚本输出
    /// </summary>
    public class JsHelper
    {
    /// <summary>
    /// 弹出信息,并跳转指定页面。
    /// </summary>
    public static void AlertAndRedirect(string message, string toURL)
    {
    string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
    HttpContext.Current.Response.Write(string.Format(js, message, toURL));
    HttpContext.Current.Response.End();
    }

    /// <summary>
    /// 弹出信息,并返回历史页面
    /// </summary>
    public static void AlertAndGoHistory(string message, int value)
    {
    string js = @"<Script language='JavaScript'>alert('{0}');history.go({1});</Script>";
    HttpContext.Current.Response.Write(string.Format(js, message, value));
    HttpContext.Current.Response.End();
    }

    /// <summary>
    /// 直接跳转到指定的页面
    /// </summary>
    public static void Redirect(string toUrl)
    {
    string js = @"<script language=javascript>window.location.replace('{0}')</script>";
    HttpContext.Current.Response.Write(string.Format(js, toUrl));
    }

    /// <summary>
    /// 弹出信息 并指定到父窗口
    /// </summary>
    public static void AlertAndParentUrl(string message, string toURL)
    {
    string js = "<script language=javascript>alert('{0}');window.top.location.replace('{1}')</script>";
    HttpContext.Current.Response.Write(string.Format(js, message, toURL));
    }

    /// <summary>
    /// 返回到父窗口
    /// </summary>
    public static void ParentRedirect(string ToUrl)
    {
    string js = "<script language=javascript>window.top.location.replace('{0}')</script>";
    HttpContext.Current.Response.Write(string.Format(js, ToUrl));
    }

    /// <summary>
    /// 返回历史页面
    /// </summary>
    public static void BackHistory(int value)
    {
    string js = @"<Script language='JavaScript'>history.go({0});</Script>";
    HttpContext.Current.Response.Write(string.Format(js, value));
    HttpContext.Current.Response.End();
    }

    /// <summary>
    /// 弹出信息
    /// </summary>
    public static void Alert(string message)
    {
    string js = "<script language=javascript>alert('{0}');</script>";
    HttpContext.Current.Response.Write(string.Format(js, message));
    }

    /// <summary>
    /// 注册脚本块
    /// </summary>
    public static void RegisterScriptBlock(System.Web.UI.Page page, string _ScriptString)
    {
    page.ClientScript.RegisterStartupScript(page.GetType(), "scriptblock", "<script type='text/javascript'>" + _ScriptString + "</script>");
    }
    }

  • 相关阅读:
    element-ui 中 el-table 根据scope.row行数据变化动态显示行内控件
    vue.js 父组件主动获取子组件的数据和方法、子组件主动获取父组件的数据和方法
    把json1赋值给json2,修改json2的属性,json1的属性也一起变化
    win10下当前目录右键添加CMD快捷方式
    element-ui
    vscode 头部注释插件
    IE浏览器new Date()带参返回NaN解决方法
    常用css
    使用DataGridView控件显示数据
    第四章 ADO.NET
  • 原文地址:https://www.cnblogs.com/moxuanshang/p/4645822.html
Copyright © 2020-2023  润新知