我试图在条件返回为 true 后重定向网页,但我似乎无法让它工作。理论上这应该,不应该。我错过了什么,有可能吗?
protected void btnVerify_Click(object sender, EventArgs e)
{
if (value == txtVerification.Text || txtVerification.Text == "****")
{
//defines a bool to tell if the popup window has been shown, this will only ever return true
bool PopupShown = doRedirect();
if(PopupShown)
{
Response.Redirect("somewebpage.aspx");
}
}
else
{
lblVerificationFailed.Visible = true;
}
}
//Opens the popup window to fire off the download and returns true
bool doRedirect()
{
string url = "GetDocs.aspx";
string s = "window.open('" + url + "', 'GetDocs', 'height=150,width=300,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
return true;
}
最佳答案
您正在尝试在服务器端做一些在客户端更容易完成的事情。
您正在使用服务器事件来捕捉 View 中按钮的点击、启动客户端弹出窗口以及稍后重定向您的页面执行。
在 javascript 上尝试这样的东西:
var btnVerify = document.getElementById("btnVerify");
btnVerify.addEventListener("click", function() {
window.open('GetDocs.aspx', 'GetDocs', 'height=150,width=300,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');
window.location.href = "somewebpage.aspx";
});
关于javascript - 弹出窗口打开后重定向到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31745199/