?? 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 + -