它确实允许我更改密码,但视图被重置为其原始状态。
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。我错过了什么?