In ASP.NET Webforms, ChangePassword: How to set SuccessTemplate to visible after changing the password?

This allows me to change the password, but the view is reset to its original state.

OnInit looks like this:

changePassword.ChangingPassword += ChangePasswordButton_Click;

and method implementation:

private void ChangePasswordButton_Click(object sender, EventArgs args)
{
 MembershipUser user = Membership.GetUser();

 string oldPassword = changePassword.CurrentPassword;
 string newPassword = changePassword.NewPassword;

 try
 {
  if (user.ChangePassword(oldPassword, newPassword))
  {
   //TODO: set successtemplate to visible. How? Who knows.
   //Response.Write("Changes were successful");
  }
  else
  {
   //Response.Write("Failed to change password");
  }
 }
 catch (ArgumentException e)
 {
  //Response.Write("Password could not be changed due to: " + e.Message);
 }
}

I need to change the password when I should, so it selects the membership provider configuration.

I have both a SuccessTemplate and a ChangePasswordTemplate in an aspx file, but I don't know how to get the ChangePassword control to display SuccessTemplate. What am I missing?

+3
source share
1 answer

( . wiki . . , ( ))

OP ():

:

changePassword.SuccessTemplate.InstantiateIn(changePassword);
changePassword.ChangePasswordTemplateContainer.Visible = false;
0

Source: https://habr.com/ru/post/1716953/


All Articles