【发布时间】:2015-07-31 11:34:26
【问题描述】:
我试图在条件返回为真后重定向网页,但我似乎无法让它工作。从理论上讲,这应该,不应该。我错过了什么,有可能吗!
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;
}
【问题讨论】:
-
我猜 Response.Redirect 之前的所有内容都会被忽略。我建议在当前页面中将弹出逻辑添加为 JavaScript。在执行回发之前显示弹出窗口(btnVerify-Click)。
标签: javascript c# asp.net .net