在 ASP.NET Webforms 中,ChangePassword:如何将 SuccessTemplate 设置为在更改密码后可见?
它确实允许我更改密码,但视图将重置为原始状态。
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。我缺少什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(通过问题编辑回答。转换为社区 wiki 答案。请参阅 问题没有答案,但问题在评论中解决(或在聊天中扩展))
OP 写道:
(Answered by a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote: