zoukankan      html  css  js  c++  java
  • asp.net ajax

    AjaxFunc.MessageBox(Page, "5", "请选择至少一种型号!");
    using System;
    using System.Web.UI;
    
    /// <summary>
    /// AJAX帮助类
    /// </summary>
    public static class AjaxFunc
    {
        /// <summary>
        /// 返回上一页
        /// </summary>
        /// <param name="ps"></param>
        public static void Back(Page ps)
        {
            ScriptManager.RegisterStartupScript(ps, ps.GetType(), "E", "<script>history.go(-1);</script>", false);
        }
    
        /// <summary>
        /// 弹出对话框
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strMsg"></param>
        public static void MessageBox(Page ps, string strName, string strMsg)
        {
            ScriptManager.RegisterClientScriptBlock(ps, ps.GetType(), strName, "alert('" + strMsg + "')", true);
        }
    
        /// <summary>
        /// 运行JavaScript脚本
        /// </summary>
        /// <param name="ps">页面</param>
        /// <param name="script">JavaScript脚本</param>
        public static void RunJavaScript(Page ps, string script)
        {
            ScriptManager.RegisterClientScriptBlock(ps, ps.GetType(), "key", script, true);
        }
    
        /// <summary>
        /// 加载网页
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strUrl"></param>
        public static void OpenUrl(Page ps, string strName, string strUrl)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName,
                                                              "window.location.href='" + strUrl + "';", true);
        }
    
        /// <summary>
        /// 弹出网页
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strUrl"></param>
        public static void OpenModelUrl(Page ps, string strName, string strUrl)
        {
            //System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName, "window.showModalDialog ('" + strUrl + "', 'newwindow', 'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');", true);
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName,
                                                              "window.showModalDialog ('" + strUrl +
                                                              "', 'newwindow', 'dialogHeight:650px, dialogWidth:300px, toolbar=no, menubar=no, resizable=no, location=no, status=no');",
                                                              true);
        }
    
        /// <summary>
        /// 弹出网页
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strUrl"></param>
        public static void OpenModelUrl(Page ps, string strName, string strUrl, int width, int height)
        {
            //System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName, "window.showModalDialog ('" + strUrl + "', 'newwindow', 'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');", true);
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName,
                                                              "window.showModalDialog ('" + strUrl +
                                                              "', 'newwindow', 'dialogHeight:" + height.ToString() +
                                                              "px; dialogWidth:" + width.ToString() +
                                                              "px; toolbar:no; resizable:no; location:no; status:no;help:no;scroll:no;');",
                                                              true);
        }
    
        /// <summary>
        /// 弹出网页+状态栏
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strUrl"></param>
        public static void OpenModelUrl_EX(Page ps, string strName, string strUrl, int width, int height)
        {
            //System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName, "window.showModalDialog ('" + strUrl + "', 'newwindow', 'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');", true);
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName,
                                                              "window.showModalDialog ('" + strUrl +
                                                              "', 'newwindow', 'dialogHeight:" + height.ToString() +
                                                              "px; dialogWidth:" + width.ToString() +
                                                              "px; toolbar:no; resizable:no; location:no; status:yes;help:no;scroll:no;');",
                                                              true);
        }
    
        /// <summary>
        /// 弹出网页
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="strName"></param>
        /// <param name="strUrl"></param>
        public static void OpenModelUrl_DW(Page ps, string strName, string strUrl)
        {
            //System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName, "window.showModalDialog ('" + strUrl + "', 'newwindow', 'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');", true);
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), strName,
                                                              "window.showModalDialog ('" + strUrl +
                                                              "', 'newwindow', 'dialogHeight:700px, dialogWidth:300px, toolbar=no, menubar=no, resizable=no, location=no, status=no');",
                                                              true);
        }
    
        /// <summary>
        /// 关闭模式网页
        /// </summary>
        /// <param name="ps"></param>
        public static void CloseModalUrl(Page ps)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(ps, ps.GetType(), "", "window.close();", true);
        }
    
        /// <summary>
        /// 使用AJAX操作Response.Write
        /// </summary>
        /// <param name="control"></param>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <param name="script"></param>
        /// <param name="addScriptTags"></param>
        public static void ResponseWrite(Control control, Type type, string script, bool addScriptTags)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(control, type, "NULL", script, addScriptTags);
        }
    }
  • 相关阅读:
    一道小学数学题
    Ubuntu下使用git提交代码至GitHub
    C#几个小知识点
    C#中巧用#if DEBUG 进行调试
    使用 HPC Pack 为 Azure 中的 Windows HPC 工作负荷创建和管理群集的选项
    使用 Chef 自动执行 Azure 虚拟机部署
    在 Azure 中管理 Windows 虚拟机的可用性
    什么是 Azure 中的虚拟机规模集?
    从 Azure 下载 Windows VHD
    如何使用 Packer 在 Azure 中创建 Windows 虚拟机映像
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075935.html
Copyright © 2011-2022 走看看