它的确允许我更改密码,但 View 已重置为其原始状态。

OnInit看起来像这样:

changePassword.ChangingPassword += ChangePasswordButton_Click;

和方法实现:
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);
 }
}

我确实需要更改密码,因此它确实提取了成员资格提供程序配置。

我在aspx文件中既有SuccessTemplate也有ChangePasswordTemplate,但是我不知道如何使ChangePassword控件显示SuccessTemplate。我想念什么?

最佳答案

(由问题编辑回答。转换为社区Wiki答案。请参见Question with no answers, but issue solved in the comments (or extended in chat))

OP写道:

解决了:

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

关于asp.net - 在ASP.NET Webforms中,ChangePassword:如何在更改密码后将SuccessTemplate设置为可见?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1382227/

10-12 15:27