温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:太糊留言板(VS2008+SQL2005)
当前文件:
TaiHuMessage/Default.aspx.cs,打开代码结构图
TaiHuMessage/Default.aspx.cs,打开代码结构图1using System; 2
using System.Configuration; 3
using System.Data; 4
using System.Data.SqlClient; 5
using System.Linq; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.HtmlControls; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.WebControls.WebParts; 12
using System.Xml.Linq; 13
14
15
16
public partial class _Default : System.Web.UI.Page 17
{ 18
DB DBManage = new DB(); 19
ShowMes sm = new ShowMes(); 20
Timer t = new Timer(); 21
22
protected void Page_Load(object sender, EventArgs e) 23
{ 24
if (!IsPostBack) 25
{ 26
27
t.Enabled = true; 28
this.time.Text = System.DateTime.Now.ToString(); 29
30
Random rd = new Random(); 31
string rand = Convert.ToString(rd.Next(10000, 99999)); 32
this.Validator.Text = rand; 33
this.Label1.Text=Application ["online"].ToString()+"\t人"; 34
this.Label2.Text = Application["total"].ToString() + "\t人"; 35
} 36
} 37
protected void SubmitLinkButton_Click(object sender, EventArgs e) 38
{ 39
40
if (this.ValidatorTextBox.Text.Equals( this.Validator.Text)) 41
{ 42
this.RequiredFieldValidator3.IsValid = true; 43
} 44
else 45
{ 46
this.RequiredFieldValidator3.IsValid = false; 47
} 48
49
50
string name = this.NameTextBox.Text; 51
string content = this.MessageTextBox.Text; 52
string SqlStr="insert into mes(name,content)values('"+name+"','"+content+"')"; 53
int n; 54
if (this.RequiredFieldValidator1.IsValid == true && this.RequiredFieldValidator2.IsValid == true && this.RequiredFieldValidator3.IsValid == true) 55
{ 56
n = DBManage.Command(SqlStr); 57
if (n > 0) 58
{ 59
Response.Redirect("ShowResult.aspx?sendmes=恭喜,留言成功!"); 60
61
} 62
} 63
this.NameTextBox.Text = ""; 64
this.MessageTextBox.Text = ""; 65
this.ValidatorTextBox.Text = ""; 66
67
68
69
} 70
71
72
73
74
75
76
77
protected void ClearLinkButton_Click(object sender, EventArgs e) 78
{ 79
this.NameTextBox.Text = ""; 80
this.MessageTextBox.Text = ""; 81
this.ValidatorTextBox .Text = ""; 82
} 83
} 84




DB DBManage 
}
}