User Information Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website - Viewing Personal Info
(Page 4 of 4 )
Viewing Personal Info
This part of the function is easily accomplished through the "UserInfo.aspx" page, whose design-time snapshot is shown in Figure 26.
Figure 26—the design-time snapshot for personal info viewing
/Building_ASP.NET_AJAX_Server-Centric_Shopping_Website(7)_html_29d52fe3.png)
As you may have guessed, this page is only for browsing, so we just need to display the original information. Since the programming logic is quite similar to that of the code discussed above and even much easier, we only give the code that is responsible for loading the user information and binding it to the related fields as follows:
protected void Page_Load(object sender,EventArgs e){
if(Session["UserID"] != null) {
nUserID = Int32.Parse(Session["UserID"].ToString());
}
else{
///Get the value of the parameter
if(Request.Params["UserID"] != null) {
if(Int32.TryParse(Request.Params["UserID"].ToString(),out nUserID) == false) {
return;
}
}
}
if(!Page.IsPostBack)
{ ///bind data to the control
if(nUserID > -1)
{
BindUserData(nUserID);
}
}
}
private void BindUserData(int nUserID) {
///Get the data
User user = new User();
SqlDataReader recr = user.GetSingleUser(nUserID);
///Read the data
if(recr.Read()){
///display data
UserName.Text = recr["UserName"].ToString();
RealName.Text = recr["RealName"].ToString();
Email.Text = recr["Email"].ToString();
Phone.Text = recr["Phone"].ToString();
Mobile.Text = recr["Mobile"].ToString();
Remark.Text = recr["Remark"].ToString();
Address.Text = recr["Address"].ToString();
}
recr.Close(); ///Close the data source
}
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |