留言板问题 前面有加个if(is什么post)了啦,我忘记了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主应该是page_Load事件中漏写了一个判断: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ..... .....//加上你自己的代码 } } using System;using System.Collections;using System.Configuration;using System.Data;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Data.OleDb;public partial class ly : System.Web.UI.Page{ public static readonly string CONN_STRING_NON_DTC = System.Configuration.ConfigurationManager.AppSettings["provider"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";"; OleDbConnection conn1 = new OleDbConnection(CONN_STRING_NON_DTC); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text != "") { if (TextBox4.Text == Session["CHKCode"].ToString()) { conn1.Open(); string name = TextBox1.Text; string email = TextBox2.Text; string qq = TextBox3.Text; string lx = DropDownList1.SelectedValue; //特殊 string tit = TextBox5.Text; string con = TextBox6.Text; string strAddSql = "Insert into ly (name,email,qq,lx,tit,con)"; strAddSql += "values ('" + name + "','" + email + "','" + qq + "','" + lx + "','" + tit + "','" + con + "')"; OleDbCommand comm518 = new OleDbCommand(strAddSql, conn1); comm518.ExecuteNonQuery(); Response.Write("<script>alert('留言成功')</script>"); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; conn1.Close(); } else { Response.Write("<script>alert('验证码不正确')</script>"); } } else { Response.Write("<script>alert('标题不得为空')</script>"); } }}代码 我得怎么改 留言成功之后,你代码是把一些textbox设置为了"",这样的话 状态还是停留在当前点击按钮的状态,看到的页面上所有textbox为空只是个错觉(可以这么理解)简单的办法就是,断开conn1之后再response.redirect("页面.aspx"); 试试吧 access查询结果返回到datagridview,请写详细...谢谢!!! 面向对象继承的问题 求助 菜鸟级 GridView 控件后台代码问题~·· 在Winform程序中如何捕获鼠标的位置 用.NET做监控SQL服务器提问 关于动态行列装换 请教高手:我在excel中选中一列,然后复制,怎么计算当前粘贴板上的内容,并按照原始的表格样式放入DataTable中 如何用Rational XDE for .Net 逆向工程? richtextbox里面的文字拖动是如何实现的? C#中devexpress组件的treelist控件如何添加水平滚动条 C#控制台如何返回上一个选择?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
.....
.....//加上你自己的代码
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OleDb;public partial class ly : System.Web.UI.Page
{
public static readonly string CONN_STRING_NON_DTC = System.Configuration.ConfigurationManager.AppSettings["provider"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";"; OleDbConnection conn1 = new OleDbConnection(CONN_STRING_NON_DTC);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ }
}
protected void Button1_Click(object sender, EventArgs e)
{ if (TextBox1.Text != "")
{
if (TextBox4.Text == Session["CHKCode"].ToString())
{
conn1.Open();
string name = TextBox1.Text;
string email = TextBox2.Text;
string qq = TextBox3.Text;
string lx = DropDownList1.SelectedValue; //特殊
string tit = TextBox5.Text;
string con = TextBox6.Text;
string strAddSql = "Insert into ly (name,email,qq,lx,tit,con)";
strAddSql += "values ('" + name + "','" + email + "','" + qq + "','" + lx + "','" + tit + "','" + con + "')";
OleDbCommand comm518 = new OleDbCommand(strAddSql, conn1);
comm518.ExecuteNonQuery();
Response.Write("<script>alert('留言成功')</script>");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
conn1.Close();
}
else
{
Response.Write("<script>alert('验证码不正确')</script>");
} }
else
{
Response.Write("<script>alert('标题不得为空')</script>");
} }
}代码 我得怎么改
,这样的话 状态还是停留在当前点击按钮的状态,看到的页面上所有textbox为空只是个错觉(可以这么理解)简单的办法就是,断开conn1之后再response.redirect("页面.aspx"); 试试吧