[英]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.