Programming an ASP.NET AJAX Server-Centric Based Online Shopping Website - Registration
(Page 3 of 4 )
Figure 8—the running-time snapshot for users to finally submit their registration info
/Building_ASP.NET_AJAX_Server-Centric_Shopping_Website(3)_html_m229734ad.png)
From the above figure, we can see that all the information displayed here is just the same as that entered in the previous step. When the user clicks the "OK" button the related user information will be saved finally into the server-side SQL Server database, while when he clicks the "Previous" button he will once more be navigated back to the previous page, "Register.aspx."
In addition, there are also two things worth mentioning. First, we use Firefox instead of IE to test the page; and second, the phone call number format follows the form "nnn-nnnnnnnn" while the mobile number format follows the form "13nnnnnnnnn" (refer to the downloaded source code).
Finally, let’s delve into the related submitting code, as follows:
protected void SureBtn_Click(object sender,EventArgs e){
if(Session[Session.SessionID + UserInfo.UserIDString] == null){
return;
}
UserInfo userInfo = (UserInfo)Session[Session.SessionID + UserInfo.UserIDString];
User user = new User();
if(user.AddUser(userInfo.UserName,
userInfo.RealName,userInfo.Password,userInfo.Address,
userInfo.Phone,userInfo.Mobile,userInfo.Email,3,userInfo.Remark) > -1)
{
Response.Write("<script>window.alert('Register successfully.')</script>");
}
else {
Response.Write("<script>window.alert('Register failure! Check your register info again.')</script>");
}
}
First, we judge whether the user has populated his registration information, or else we do nothing. Next, we obtain the user registration information via the browser variable Sessionand save it into a UserInfoinstance. Then, by invoking a member function, namelyAddUserof the instance of class Userthe details of the user registration are persisted into the back-end database table User. Finally, we display the information of the operating result via the typical "Response.Write" invocation. That’s all.
Next: Logging On and Logging Off >>
More ASP.NET Articles
More By Xianzhong Zhu