惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
N
News and Events Feed by Topic
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Engineering at Meta
Engineering at Meta
Google Online Security Blog
Google Online Security Blog
宝玉的分享
宝玉的分享
AI
AI
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
H
Hacker News: Front Page
F
Fortinet All Blogs
博客园_首页
S
Secure Thoughts
N
News and Events Feed by Topic
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Spread Privacy
Spread Privacy
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Know Your Adversary
Know Your Adversary
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
PCI Perspectives
PCI Perspectives
L
LangChain Blog
雷峰网
雷峰网
Security Archives - TechRepublic
Security Archives - TechRepublic
V2EX - 技术
V2EX - 技术

博客园 - 叶子绿了

freemarker显示含有html代码的内容 .net sql 防注入 httpmodule [转载]poi导出excel,可以自定义保存路径 jquery ajax 传递js对象到后台 Struts2下多文件的上传与下载 dwr框架 Oracle 9i中包含Connect by 子句的查询向Oracle 10g移植后运行时错误及解决方法 JQuery Uploadify 基于JSP的无刷新上传实例 写了个用jquery控制select只读(select选项可以供用户查看但不能改变初始选中值) C#之模态窗口关闭 repeater相同行合并 在Web站点中创建和使用Rss源(动态) silverlight xml查询 silverlight 3 数据绑定及分页 解决ASP.NET中Image控件不能自动刷新 导入Excel数值读不到,找不到可安装的 ISAM错误! asp.net2.0 上传大容量文件第三方控件radupload 浏览器不能正常解析CSS代码的解决 ajax在用户注册中的应用,类似淘宝网
解决UpdatePanel无法直接弹出窗口的问题
叶子绿了 · 2010-04-21 · via 博客园 - 叶子绿了

/// <summary>
    /// 自定义弹出窗口内容
    /// </summary>
    /// <param name="msg"></param>
    public static void AjaxShowWindows(string msg)
    {
        //myContext.Response.Write("<script>彈出窗口代碼(wondows.open(XXX));</script>");
        string script="彈出窗口代碼(wondows.open(XXX));"; //注意彈出窗口的ID,最好使用隨機,否則只能彈出一次
        ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowWindows", script, true);
    }

==========參考代碼===========

using System;
using System.Collections.Generic;
using System.Text;

using System.Web;
using System.Web.UI;

public class ShowMessage
{
    /// <summary>
    /// 自定义弹出窗口内容,不跳转
    /// </summary>
    /// <param name="page"></param>
    /// <param name="msg"></param>
    public static void Show(System.Web.UI.Page page, string msg)
    {
        page.ClientScript.RegisterStartupScript(page.GetType(), "ShowMessage", "alert('" + msg + "');", true);
    }
    /// <summary>
    /// 自定义弹出窗口内容,并跳转
    /// </summary>
    /// <param name="page"></param>
    /// <param name="msg"></param>
    /// <param name="returnUrl"></param>
    public static void Show(System.Web.UI.Page page, string msg, string returnUrl)
    {
        page.ClientScript.RegisterStartupScript(page.GetType(), "ShowMessage", "alert('" + msg + "');window.location.href='" + returnUrl + "';", true);
    }
    /// <summary>
    /// 自定义弹出窗口内容,并跳转
    /// </summary>
    /// <param name="page"></param>
    /// <param name="msg"></param>
    /// <param name="returnUrl"></param>
    public static void Show(System.Web.UI.Page page, string msg, string trueReturnUrl, string falseReturnUrl)
    {
        page.ClientScript.RegisterStartupScript(page.GetType(), "ShowMessage", "if(confirm('" + msg + "')){javascript:location='" + trueReturnUrl + "';}else{javascript:location='" + falseReturnUrl + "';}", true);
    }

    /// <summary>
    /// 自定义弹出窗口内容
    /// </summary>
    /// <param name="msg"></param>
    public static void AjaxShow(string msg)
    {
        //myContext.Response.Write("<script>alert('" + msg + "');</script>");
        ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "alert('" + msg + "');", true);
    }
    /// <summary>
    /// 自定义弹出窗口内容并直接转向一个新的页面
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="url"></param>
    public static void AjaxShow(string msg, string url)
    {
        //myContext.Response.Write("<script>alert('" + msg + "');javascript:location='"+Url+"';</script>");
        ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "alert('" + msg + "');javascript:location='" + url + "';", true);

    }
    /// <summary>
    /// 自定义弹出窗口内容并选择是直接转向,还是提示转向一个新的页面
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="isreturn"></param>
    /// <param name="url"></param>
    public static void AjaxShow(string msg, bool isreturn, string url)
    {
        if (!isreturn)
        {
            //myContext.Response.Write("<script>alert('" + msg + "');javascript:location='"+Url+"';</script>");
            ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "alert('" + msg + "');javascript:location='" + url + "';", true);
        }
        else
        {
            //myContext.Response.Write("<script>alert('" + msg + "');javascript:location='"+Url+"';</script>");
            ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "if(confirm('" + msg + "')){javascript:location='" + url + "';}", true);
        }

    }
    /// <summary>
    /// 自定义弹出窗口内容,自定义是否关闭当前页面
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="close"></param>
    public static void AjaxShow(string msg, bool close)
    {
        if (close)
        {
            // myContext.Response.Write("<script>alert('" + msg + "');javascript:window.close();</script>");
            ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "alert('" + msg + "');javascript:window.close();", true);
        }
        else
        {
            //myContext.Response.Write("<script>alert('" + msg + "');</script>");
            ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "ShowMessage", "alert('" + msg + "');", true);
        }
    }
}

转贴自 http://kb.cnblogs.com/a/1336111/