简体   繁体   English

使用ASP.Net按钮弹出单击弹出窗口阻止程序未阻止

[英]Pop-Up with ASP.Net Button Click that is not blocked with popup blocker

I currently have an ASP.Net button click event that does a few things (including change session variables) prior to registering a new startup script As is, when a user clicks the button, their pop-up blocker blocks the popup even though it was technically triggered by a user event; 我目前有一个ASP.Net按钮单击事件,在注册新的启动脚本之前执行一些操作(包括更改会话变量)当用户单击按钮时,他们的弹出窗口阻止程序会阻止弹出窗口,即使它是技术上由用户事件触发; I imagine the browser doesn't see it that way. 我认为浏览器不会这样看。

protected void ContinueButton_Click(object sender, EventArgs e)
{
    if (agreement.Checked)
    {
        string eid = Request.QueryString["eid"];
        Session["TestAgreement"] = "Agreed";
        openNewWindow("Exams/exam.aspx?id=" + courseCode, "height=760, width=1000, status=yes, toolbar=no, menubar=no, location=no, scrollbars=1");
    }          
}
private void openNewWindow(string url, string parameters)
{
    ClientScript.RegisterStartupScript(this.GetType(), "Exam", String.Format("<script>window.open('" + url + "', '', '" + parameters + "');</script>"));
}

AjaxControlToolkit's modal popup works nicely for this sort of thing. AjaxControlToolkit的模态弹出窗口很适合这种事情。

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

its still within the asp.net framework so you still get all your server side goodness, and you can always pop a usercontrol inside of it so that you can treat it as a separate "page" 它仍然在asp.net框架内,因此您仍然可以获得所有服务器端的优点,并且您可以随时在其中弹出用户控件,以便您可以将其视为单独的“页面”

just remember to keep your cclientidmode on your objects as static or predictable if you want to be able to hit them from your client side. 如果您希望能够从客户端点击它们,请记住将对象的cclientidmode保持为静态或可预测。

Do it with javascript. 用javascript做吧。 Do not open a new Window, just set a div in front and change its content. 不要打开一个新窗口,只需在前面设置一个div并更改其内容即可。

The easiest would be, to use Jquery Dialog: 最简单的是,使用Jquery Dialog:

http://api.jqueryui.com/dialog/ http://api.jqueryui.com/dialog/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 (ASP.NET)如何执行此操作:在GridView中单击按钮以打开包含另一个Gridview的弹出窗口 - (ASP.NET) How to do this: Button click in GridView to open pop-up window containing another Gridview 单击按钮后,单击“显示弹出窗口一段时间”,然后重定向页面-ASP.NET - Upon Button Click Display Pop-Up for Certain Time and then Redirect Page - ASP.NET 如何使button_Click事件在ASP.NET的弹出窗口中打开页面? - How to make the button_Click event opens the page in a pop-up window in ASP.NET? 如何在ASP.NET Datagrid中弹出日历? - How to pop-up a calendar inside an ASP.NET Datagrid? 在ASP.NET中调用弹出的“确认”消息框 - Invoking a pop-up 'confirm' message box in ASP.NET 防止ASP弹出窗口弹出阻止程序 - Prevent asp popup window from pop up blocker 如何通过ASP.NET显示弹出对话框并获取弹出窗口的值 - How to show a pop-up dialog through ASP.NET and get the value of the pop up back ASP.NET 如何在不关闭或刷新弹出窗口的情况下使用模态弹出引导程序 4 上的按钮 - ASP.NET How to use button on modal Pop Up Bootstrap 4 without closing or refreshing popup 如何通过单击按钮在asp.Net中打开一个弹出窗口 - how to open a pop up window via button click in asp.Net 使用ASP.NET C#不会出现模式弹出窗口 - Modal pop-up is not appearing using asp.net c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM