您目前尚未登陆,请选择【登陆】或【注册
首页->留言本类->晶晶Vb.net留言板源码>>write.aspx.vb>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:晶晶Vb.net留言板源码
当前文件:文件类型 VbGuestBook/write.aspx.vb打开代码结构图
普通视图
		            
1Imports System 2Imports System.IO 3Imports System.ComponentModel 4Imports System.Data 5Imports System.Data.OleDb 6Imports System.Web 7Imports System.Web.SessionState 8Imports System.Web.UI 9Imports System.Web.UI.WebControls 10Imports System.Configuration 11Imports Microsoft.VisualBasic 12 13Public Class write 14 Inherits System.Web.UI.Page 15 Protected WithEvents name As System.Web.UI.WebControls.TextBox 16 Protected WithEvents email As System.Web.UI.WebControls.TextBox 17 Protected WithEvents qq As System.Web.UI.WebControls.TextBox 18 Protected WithEvents homepage As System.Web.UI.WebControls.TextBox 19 Protected WithEvents title As System.Web.UI.WebControls.TextBox 20 Protected WithEvents thetext As System.Web.UI.WebControls.TextBox 21 Protected WithEvents gg As System.Web.UI.WebControls.RadioButton 22 Protected WithEvents mm As System.Web.UI.WebControls.RadioButton 23 Protected WithEvents face As System.Web.UI.WebControls.DropDownList 24 Protected WithEvents Button1 As System.Web.UI.WebControls.Button 25 26Web 窗体设计器生成的代码 40 41 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 42 Dim PostTime As String, cie As HttpCookie 43 cie = Request.Cookies("rwfj") 44 If Not (cie Is Nothing) Then 45 PostTime = cie.Values("PostTime") 46 If PostTime <> "" Then 47 If DateDiff(DateInterval.Second, CType(PostTime, Date), Date.Now) < Int(ConfigurationSettings.AppSettings("发帖间隔")) Then Response.Redirect("info.aspx?ID=6,") 48 End If 49 End If 50 Dim FoundErr As Boolean = False, ID As String, iface As String 51 Dim iname As String, iemail As String, iqq As String, ihp As String, ititle As String, itext As String, sex As String 52 iname = Server.HtmlEncode(Trim(name.Text)) 53 iemail = Server.HtmlEncode(Trim(email.Text)) 54 iqq = Trim(qq.Text) 55 ihp = Server.HtmlEncode(Trim(homepage.Text)) 56 ititle = Server.HtmlEncode(Trim(title.Text)) 57 itext = Trim(thetext.Text) 58 iface = Server.HtmlEncode(Trim(face.SelectedItem.Value)) 59 If iname.Length < 1 Then 60 FoundErr = True 61 ID += "1," 62 ElseIf Session("name") <> ConfigurationSettings.AppSettings("站长") And iname = ConfigurationSettings.AppSettings("站长") Then 63 FoundErr = True 64 ID += "3," 65 End If 66 If itext.Length < 1 Then 67 FoundErr = True 68 ID += "2," 69 End If 70 If iemail.Length > 0 And (InStr(iemail, "@") = 0 Or InStr(iemail, ".") = 0 Or iemail.Length < 7) Then 71 FoundErr = True 72 ID += "4," 73 End If 74 If iqq.Length > 0 And (iqq.Length < 5 Or IsNumeric(iqq) = False) Then 75 FoundErr = True 76 ID += "5," 77 End If 78 If FoundErr = True Then Response.Redirect("info.aspx?ID=" + ID) 79 If UCase(ConfigurationSettings.AppSettings("允许HTML")) = "NO" Then 80 itext = Server.HtmlEncode(itext) 81 End If 82 If mm.Checked = True Then 83 sex = "美女" 84 Else 85 sex = "帅哥" 86 End If 87 If iname.Length > 20 Then iname = Left(iname, 20) 88 If iemail.Length < 1 Then iemail = "(保密)" 89 If iemail.Length > 50 Then iemail = Left(iemail, 50) 90 If iqq.Length < 1 Then iqq = "(保密)" 91 If iqq.Length > 15 Then iqq = Left(iqq, 15) 92 If ihp.Length < 1 Then ihp = "(保密)" 93 If ihp.Length > 100 Then ihp = Left(ihp, 100) 94 If ititle.Length < 1 Then ititle = "(无标题)" 95 If ititle.Length > 40 Then ititle = Left(ititle, 40) 96 If iface.Length > 50 Then iface = Left(iface, 50) 97 itext = Trim(itext) 98 itext = "&nbsp;&nbsp;" + itext + "&nbsp;&nbsp;" 99 itext = Replace(itext, vbCrLf, "<br>&nbsp;&nbsp;") 100 If itext.Length > Int(ConfigurationSettings.AppSettings("留言长度限制")) Then itext = Left(itext, Int(ConfigurationSettings.AppSettings("留言长度限制"))) 101 Dim conn As OleDbConnection, comd As OleDbCommand 102 conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(ConfigurationSettings.AppSettings("数据库"))) 103 comd = New OleDbCommand("Insert into 留言(标题,作者,内容,性别,主页,信箱,QQ,IP,头像) Values(@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9)", conn) 104 With comd.Parameters 105 .Add(New OleDbParameter("@p1", OleDbType.Char)) 106 .Add(New OleDbParameter("@p2", OleDbType.Char)) 107 .Add(New OleDbParameter("@p3", OleDbType.Char)) 108 .Add(New OleDbParameter("@p4", OleDbType.Char)) 109 .Add(New OleDbParameter("@p5", OleDbType.Char)) 110 .Add(New OleDbParameter("@p6", OleDbType.Char)) 111 .Add(New OleDbParameter("@p7", OleDbType.Char)) 112 .Add(New OleDbParameter("@p8", OleDbType.Char)) 113 .Add(New OleDbParameter("@p9", OleDbType.Char)) 114 End With 115 comd.Parameters("@p1").Value = ititle 116 comd.Parameters("@p2").Value = iname 117 comd.Parameters("@p3").Value = itext 118 comd.Parameters("@p4").Value = sex 119 comd.Parameters("@p5").Value = ihp 120 comd.Parameters("@p6").Value = iemail 121 comd.Parameters("@p7").Value = iqq 122 comd.Parameters("@p8").Value = Request.ServerVariables("REMOTE_ADDR") 123 comd.Parameters("@p9").Value = iface 124 comd.Connection.Open() 125 comd.ExecuteNonQuery() 126 comd.Connection.Close() 127 comd.Dispose() 128 conn.Close() 129 conn.Dispose() 130 Dim ds As DataSet, TheTime As Date 131 ds = New DataSet() 132 ds.ReadXml(Server.MapPath("data/count.xml")) 133 TheTime = CType(ds.Tables(0).Rows(0)(4), Date) 134 If DateValue(TheTime) = DateValue(Date.Now) Then 135 ds.Tables(0).Rows(0)(0) = Int(ds.Tables(0).Rows(0)(0)) + 1 136 Else 137 ds.Tables(0).Rows(0)(0) = 1 138 End If 139 ds.Tables(0).Rows(0)(2) = Int(ds.Tables(0).Rows(0)(2)) + 1 140 ds.Tables(0).Rows(0)(4) = Date.Now 141 ds.AcceptChanges() 142 ds.WriteXml(Server.MapPath("data/count.xml")) 143 ds.Dispose() 144 cie = New HttpCookie("rwfj") 145 cie.Values.Add("PostTime", Date.Now.ToString) 146 cie.Values.Add("name", "guest") 147 Response.AppendCookie(cie) 148 Response.Redirect("default.aspx") 149 End Sub 150 151 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 152 If Not IsPostBack Then 153 Dim dir As Directory, fs As String(), i As Integer 154 fs = dir.GetFiles(Server.MapPath("face\")) 155 For i = 0 To UBound(fs) 156 fs(i) = Replace(fs(i), Server.MapPath("face\"), "") 157 Next 158 face.DataSource = fs 159 face.DataBind() 160 End If 161 End Sub 162 163End Class 164
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:晶晶Vb.net留言板源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号