HTML side
<asp:label id="lbUsername" runat="server">Select UserName:</asp:label>
<asp:textbox id="Username" runat="Server"></asp:textbox>
<asp:label id="lbNewPassword" runat="server">New Password:</asp:label>
<asp:textbox id="NewPassword" runat="Server"></asp:textbox>
<asp:button id="reset" runat="server" onclick="reset_Click" />
//code back at the back or script c#
protected void reset_Click(object sender, EventArgs e)
{
MembershipUser u;
string oldPassword;
u = Membership.GetUser(UserName.Text, false);
try
{
//reset the password and assign it to oldPassword variable
oldPassword = u.ResetPassword();
//call the change password to change the auto reset password to your desired password.
try
{
u.ChangePassword(oldPassword, NewPassword.Text);
rsetError.Text = "Password Hass been successfully Change";
}
catch(MembershipPasswordException e1)
{
rsetError.Text = "Error .";
rsetError.Text += e1.Message;
}
}
catch (MembershipPasswordException e2)
{
rsetError.Text = "Error .";
rsetError.Text +=e2.Message;
return;
}
}
I have program it this way so that instead of give the user the auto generated password you can reset the password base on the password as supplied on the textbox called new password.