views:

385

answers:

1

It does allow me to change the password but the view is reset to its original state.

OnInit looks like this:

changePassword.ChangingPassword += ChangePasswordButton_Click;

and the 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 do get to change the password when I'm supposed to, so it does pickup the membership provider configuration.

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

edit:

Solved:

changePassword.SuccessTemplate.InstantiateIn(changePassword);
changePassword.ChangePasswordTemplateContainer.Visible = false;
A: 

No, that didn't do it either. How hard can it be?!

If anyone could refer me a tutorial that shows how to use custom templates and which events to hookup etc I'd be extremely grateful. I'm going slightly mad here...

Adam Asham