gpt4 book ai didi

asp.net - 在 ASP.NET Webforms 中,ChangePassword : how do I set SuccessTemplate to visible after password's been changed?

转载 作者:行者123 更新时间:2023-12-02 05:14:59 25 4
gpt4 key购买 nike

它允许我更改密码,但 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 写道:

Solved:

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

关于asp.net - 在 ASP.NET Webforms 中,ChangePassword : how do I set SuccessTemplate to visible after password's been changed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1382227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com