User Information Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website (Page 1 of 4 )
In this seventh part of an eleven-part series, we will research common user information management tasks. This includes the topics of changing the password, modifying personal information, viewing private information, viewing the order information (discussed earlier), and more.
A
downloadable .rar file is available for this article.
User Information Center
Let's begin by discussing how to provide a feature that allows the users to modify their passwords.
Editing Password
This part is done through the "EditUserPwd.aspx" page whose design-time snapshot is shown in Figure 24 below.
Figure 24—the page for the common users to edit password
/Building_ASP.NET_AJAX_Server-Centric_Shopping_Website(7)_html_5e7952c2.png)
First of all, the ScriptManagercontrol is a must. Second, the Toolkit control PasswordStrengthmaybe the only thing that attracts our attention. Yes, as you may have imagined, when the user wants to change his password, besides verifying his old password with data in the database, we use the PasswordStrengthcontrol to confirm the safety strength of the newly-entered password and give him a friendly hint. Besides this, we have also leveraged two Validators, theRequiredFieldValidatorand the CompareValidatorto make sure the user enters the proper new password.
The following only lists the code that is associated with the event handler of the "OK" button:
protected void SureBtn_Click(object sender,EventArgs e){
User user = new User();
SqlDataReader dr = user.GetUserLogin(UserName.Text.Trim(),OldPassword.Text.Trim());
///read the value of UserID
string sUserID = "";
if(dr.Read()) { sUserID = dr["UserID"].ToString(); }
///Close the data source
dr.Close();
///judge whether the old password he enters is correct or not
if(sUserID == null || sUserID == "" || sUserID.Length < 0){
Response.Write("<script>alert('" + "The old password is invalid. Please enter again!"
+ "');</script>");
return;
}
///Change the user password
user.UpdateUserPwd(nUserID,NewPassword.Text.Trim());
Response.Write("<script>alert('" + "You have successfully modified the password. Keep your data safely!"
+ "');</script>");
}
Here, there are already enough comments. The entire logic is easy to grasp, isn’t it?
Next: Modifying Personal Info >>
More ASP.NET Articles
More By Xianzhong Zhu