質問

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

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);

And in your Javascript Write Redirect

    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帰属
所属していません StackOverflow
scroll top