createaccount.aspx.cs
来自「ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码」· CS 代码 · 共 52 行
CS
52 行
using BookShop.Model;
using BookShop.BLL;
using BookShop.Web.Controls;
//using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BookShop.Web {
public class CreateAccount : Page {
// Assume a duplicate record is the reason for the error
private const string MSG_FAILURE = "用户名已存在!请重试.";
protected TextBox txtUserId;
protected TextBox txtPassword;
protected TextBox txtEmail;
protected RequiredFieldValidator valUserId;
protected AddressUI addr;
protected NavBar header;
protected System.Web.UI.WebControls.RequiredFieldValidator valPassword;
protected System.Web.UI.WebControls.RequiredFieldValidator valEmail;
protected System.Web.UI.WebControls.ImageButton btnSubmit;
protected System.Web.UI.HtmlControls.HtmlForm frmCreateAcct;
protected Preferences prefs;
protected void SubmitClicked(object sender, ImageClickEventArgs e) {
if (Page.IsValid) {
string userId = WebComponents.CleanString.InputText(txtUserId.Text, 50);
string password = WebComponents.CleanString.InputText(txtPassword.Text, 50);
string email = WebComponents.CleanString.InputText(txtEmail.Text, 50);
AddressInfo address = addr.Address;
string language = prefs.Language;
string favCategory = prefs.Category;
bool showFavorites = prefs.IsShowFavorites;
bool showBanners = prefs.IsShowBanners;
// Store all the customers information in an account business entity
AccountInfo accountInfo = new AccountInfo(userId, password, email, address, language, favCategory, showFavorites, showBanners);
ProcessFlow.AccountController accountController = new ProcessFlow.AccountController();
if (!accountController.CreateAccount(accountInfo)){
// Tell the user they have failed to create an account
valUserId.ErrorMessage = MSG_FAILURE;
valUserId.IsValid = false;
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?