2009-09-05 45 views
3

它確實允許我更改密碼,但視圖會重置爲其原始狀態。在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。我錯過了什麼?

回答

相關問題