繁体   English   中英

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

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

我目前有一个ASP.Net按钮单击事件,在注册新的启动脚本之前执行一些操作(包括更改会话变量)当用户单击按钮时,他们的弹出窗口阻止程序会阻止弹出窗口,即使它是技术上由用户事件触发; 我认为浏览器不会这样看。

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的模态弹出窗口很适合这种事情。

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

它仍然在asp.net框架内,因此您仍然可以获得所有服务器端的优点,并且您可以随时在其中弹出用户控件,以便您可以将其视为单独的“页面”

如果您希望能够从客户端点击它们,请记住将对象的cclientidmode保持为静态或可预测。

用javascript做吧。 不要打开一个新窗口,只需在前面设置一个div并更改其内容即可。

最简单的是,使用Jquery Dialog:

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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM