温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:学习型留言板源码
当前文件:
StudyLeaveWord/reg.aspx.cs,打开代码结构图
StudyLeaveWord/reg.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
using System.Collections.Generic; 13
//该源码下载自www.51aspx.com(51aspx.com) 14
15
public partial class reg : System.Web.UI.Page 16
{ 17
private const string sql = "insert into login values(@UserName,@Password,@Email,@Phone,@Address)"; 18
private const string userName = "@UserName"; 19
private const string passWord = "@Password"; 20
private const string email = "@Email"; 21
private const string phone = "@Phone"; 22
private const string address = "@Address"; 23
protected void Page_Load(object sender, EventArgs e) 24
{ 25
26
} 27
private SqlParameter[] getParam() 28
{ 29
SqlParameter[] param = SqlHelp.GetCachedParameters(sql); 30
if (param == null) 31
{ 32
param = new SqlParameter[] { new SqlParameter(userName,SqlDbType.VarChar,20), 33
new SqlParameter(passWord,SqlDbType.VarChar,20), 34
new SqlParameter(email,SqlDbType.VarChar,50), 35
new SqlParameter(phone,SqlDbType.VarChar,12), 36
new SqlParameter(address,SqlDbType.VarChar,20) 37
}; 38
SqlHelp.CacheParameters(sql, param); 39
} 40
return param; 41
} 42
private bool regMember(IList<string> list) 43
{ 44
SqlParameter[] param = getParam(); 45
param[0].Value = list[0].ToString(); 46
param[1].Value = list[1].ToString(); 47
param[2].Value = list[1].ToString(); 48
param[3].Value = list[1].ToString(); 49
param[4].Value = list[1].ToString(); 50
bool flag = Convert.ToBoolean(SqlHelp.getExecuteNonQuery(SqlHelp.con,CommandType.Text,sql,param)); 51
return flag; 52
} 53
protected void btnreg_Click(object sender, EventArgs e) 54
{ 55
if (Page.IsValid) 56
{ 57
IList<string> list = new List<string>(); 58
list.Add(this.txtUserName.Text.Trim()); 59
list.Add(this.txtPassword.Text.Trim()); 60
list.Add(this.txtEmail.Text.Trim()); 61
list.Add(this.txtPhone.Text.Trim()); 62
list.Add(this.txtAddress.Text.Trim()); 63
if (regMember(list)) 64
{ 65
FormsAuthentication.RedirectFromLoginPage(list[0].ToString(), false, null); 66
Response.Redirect("index.aspx"); 67
} 68
} 69
} 70
} 71





}
}