简体   繁体   English

重定向到ASP.NET中的其他页面时,确认框不起作用

[英]Confirm Box is not working while redirecting to other page in ASP.NET

I am implementing one page where user changes his password. 我正在实现一页用户更改密码的页面。 Once he successfully changes his password I want to show a confirm box to user that Your password is successfully changed and You will be redirected to Login Page. 一旦他成功更改了密码,我想向用户显示一个确认框,告知您您的密码已成功更改,您将被重定向到登录页面。 So once User selects OK, he will be redirected to Login Page. 因此,一旦用户选择确定,他将被重定向到登录页面。 Here in my case I after changing password successfully, I am not get confirm box, but it is simply redirecting to login page. 在我的情况下,我成功更改密码后,没有得到确认框,只是重定向到登录页面。 I want to show confirm box to the User. 我想向用户显示确认框。 This is my Code. 这是我的代码。

 ScriptManager.RegisterStartupScript (this, typeof(string), "NavigateToLoginPage", String.Format("NavigateToLoginPage();"), true);
Session.RemoveAll();
Session.Clear();
Response.Redirect("LoginPage.aspx", false);
Context.ApplicationInstance.CompleteRequest();

this is my javascript code 这是我的JavaScript代码

function NavigateToLoginPage()
{

var message = confirm("Password is changed successfully, You will be redirected to Login Page. Please confirm");

if(message == true)
{

return true;
}
else
{
return false;
}
}

Please suggest me how can I achieve the desired functionality. 请建议我如何实现所需的功能。

You need Remove Response.Redirect("LoginPage.aspx", false); 您需要Remove Response.Redirect("LoginPage.aspx", false);

And in your Javascript Write Redirect 然后在您的Javascript中写入重定向

function NavigateToLoginPage()
    {

    var message = confirm("Password is changed successfully, You will be redirected to Login Page. Please confirm");

     if(message == true)
     {
        document.location.href='LoginPage.aspx'
     }
     else
     {
     return false;
     }
    }

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

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