protected void btnSubmit_Click(object sender, EventArgs e)
{
string name = txtName.Text;
string phone = txtPhone.Text;
string title = txtTitle.Text;
string content = txtContent.Text;
string date = DateTime.Now.ToString();
if (content.Length > 255)
{
content = content.Substring(0, 255);
}
if (name != "" & phone != "" & title != "" & content != "")
{
dbConnect dbcon = new dbConnect();
dbcon.insertLiuyan(name, phone, title, content, date);
txtName.Text = "";
txtPhone.Text = "";
txtTitle.Text = "";
txtContent.Text = "";
txtCheckCode.Text = "";
RegisterClientScriptBlock("insertSuccess", "<script>alert('您的留言已提交成功,敬请期待我们给您的答复!')</script>");
}
}
如果您用的是Web Form,像这样直接用文本框名称.文本框属性就可以了。
protected void Page_Load(object sender, EventArgs e)
{
mobileRedirect();
string keyword = Request.QueryString["keyword"];
if (keyword == null || keyword.Trim() == "")
{
keyword = "#";
}
使用Request.QueryString[""]方法,引号中是表单的名称。