📄 guestbook.aspx.cs
字号:
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Guestbook : System.Web.UI.Page
{
public string Titlep;
public string Descriptionp;
public string Keywordsp;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.DataBind();
}
//title,des,con
GetContent drt = new GetContent();
OleDbDataReader drf = drt.GetTDC();
while (drf.Read())
{
this.Titlep = drf["Title"].ToString();
this.Descriptionp = drf["Description"].ToString();
this.Keywordsp = drf["Keywords"].ToString();
}
drf.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
string title = FunStr(Request.Form["title"]);
string email = FunStr(Request.Form["email"]);
string tel = FunStr(Request.Form["tel"]);
string addr = FunStr(Request.Form["addr"]);
string name = FunStr(Request.Form["UserName"]);
string content = FunStr(Request.Form["content"]);
OleDbConnection myconn = DB.CreateDB();
myconn.Open();
OleDbCommand cmd = new OleDbCommand("insert into guestbook(title,email,tel,addr,name,content) values('" + title + "','" + email + "','" + tel + "','" + addr + "','" + name + "','" + content + "')", myconn);
cmd.ExecuteNonQuery();
Response.Write("<script language=javascript>window.alert('留言成功,现在返回留言页面');window.location.href='Guestbook.aspx';</script>");
myconn.Close();
}
public static string FunStr(string str)
{
str = str.Replace("'", "‘");
str = str.Replace(" ", " ");
str = str.Trim();
if (str.Trim().ToString() == "")
str = "无";
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -