I want to change the user’s password Question and Answer by calling the method ChangePasswordQuestionAndAnswer
MembershipUser user = Membership.GetUser(userName);
string password = user.GetPassword(); // error here
string sQuestion = DropDownList1.SelectedValue.ToString();
string sAnswer = txtAnswer.Text.ToString();
user.ChangePasswordQuestionAndAnswer(password, sQuestion, sAnswer);
But I am an administrator; I can not pass the user’s password because I do not know it.
Since you are already asking the user to enter data, why not ask again for the password? Then you can use that with the same code, just setting the password to the value of a text box.
An alternative is to automatically reset the password, then ask the user to change it to a better password choice:
The latter is not a great solution because it requires additional steps to occur after this code.