ScriptManager.RegisterStartupScript 对页面重定向不起作用

ScriptManager.RegisterStartupScript doesn't work on page redirection

我有这段代码,运行良好:

if (ddlAuditComplete.SelectedItem.Value == "3")
{
    vState = 3;
    BindAccordions(Convert.ToInt32(Session["PlanID"]), Convert.ToInt32(Session["AuditID"]));
    if (vExit == 2)
    {
        ScriptManager.RegisterStartupScript(btnAuditComplete, typeof(Button), "Data Entry", "alert('At least one plan has not been closed properly')", true);
        return;
    }
}

现在,我需要做的是抛出该弹出窗口,然后将它们重定向到另一个页面。

我试过了,但不行:

if (ddlAuditComplete.SelectedItem.Value == "3")
{
    vState = 3;
    BindAccordions(Convert.ToInt32(Session["PlanID"]), Convert.ToInt32(Session["AuditID"]));
    if (vExit == 2)
    {
        ScriptManager.RegisterStartupScript(btnAuditComplete, typeof(Button), "Data Entry", "alert('At least one plan has not been closed properly')", true);
        String SUrl = "frmAuditSearch.aspx";
        Server.Transfer(SUrl, true);
        return;
    }
}

以上代码会将用户带到另一个页面,但弹出窗口永远不会显示。

谁能告诉我这两个怎么做?理想情况下,弹出窗口将显示,一旦用户单击“确定”,它将把他们重定向到另一个页面。但如果用户首先被重定向然后弹出窗口出现,我也会接受它。

尝试先显示消息,然后重定向到下一页。

ScriptManager.RegisterStartupScript(btnAuditComplete, typeof(Button), "Data Entry", 
"alert('At least one plan has not been closed properly');window.location ='"+ SUrl +"';", true);

并删除:

Server.Transfer(SUrl, true);
return;