aspx 代码
<div align="center">
<asp:ChangePassword ID="ChangePassword1" runat="server" BackColor="#F7F7DE"
BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="10pt"
onchangedpassword="ChangePassword1_ChangedPassword">
<TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
</asp:ChangePassword>
</div>
.cs 文件代码
public partial class admin_Changepwd : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
SqlCommand cmd;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ChangePassword1_ChangedPassword(object sender, EventArgs e)
{
cmd = new SqlCommand("update Admin set Password ='" + ChangePassword1.ConfirmNewPassword + "' where userid = '" + Session["userid"] + "' and Password ='" + ChangePassword1.CurrentPassword + "'", con);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}