我前台页放了几个text,可是点击提交后,后台总是提交text里原有的字符,我修改的就返回不了,为什么啊,高手帮忙!!!!!
代码如下:
protected void Page_Load(object sender, EventArgs e)
{
try
{
SqlConnection con = db.createcon();
con.Open();
SqlCommand com = new SqlCommand("select webname,website,webtel,webcopyright from fw_config", con);
SqlDataReader dr= com.ExecuteReader();
dr.Read();
this.txtwebname.Text = dr.GetValue(0).ToString();
this.txtwebsite.Text = dr.GetValue(1).ToString();
this.txtwebtel.Text = dr.GetValue(2).ToString();
this.txtwebcopyright.Text = dr.GetValue(3).ToString();
dr.Close();
com.Dispose();
con.Close();
}
catch (Exception)
{
Response.Write("<script>alert('提取数据错误!');</script>");
Response.End();
}
}
protected void setsave_Click(object sender, EventArgs e)
{
string webname = txtwebname.Text;
string website = txtwebsite.Text;
string webtel = txtwebtel.Text;
string webcopyright = txtwebcopyright.Text; Response.Write("<script>alert('" + webname + "');</script>");
try
{
SqlConnection con = db.createcon();
con.Open();
SqlCommand com = new SqlCommand("update fw_config set webname='"+webname+"',website='"+website+"',webtel='"+webtel+"',webcopyright='"+webcopyright+"'", con);
com.ExecuteNonQuery();
com.Dispose();
con.Close();
Response.Write("<script>alert('修改完成!');location='config.aspx';</script>");
}
catch (Exception)
{
Response.Write("<script>alert('异常错误,更新失败!');</script>");
Response.End();
} }
代码如下:
protected void Page_Load(object sender, EventArgs e)
{
try
{
SqlConnection con = db.createcon();
con.Open();
SqlCommand com = new SqlCommand("select webname,website,webtel,webcopyright from fw_config", con);
SqlDataReader dr= com.ExecuteReader();
dr.Read();
this.txtwebname.Text = dr.GetValue(0).ToString();
this.txtwebsite.Text = dr.GetValue(1).ToString();
this.txtwebtel.Text = dr.GetValue(2).ToString();
this.txtwebcopyright.Text = dr.GetValue(3).ToString();
dr.Close();
com.Dispose();
con.Close();
}
catch (Exception)
{
Response.Write("<script>alert('提取数据错误!');</script>");
Response.End();
}
}
protected void setsave_Click(object sender, EventArgs e)
{
string webname = txtwebname.Text;
string website = txtwebsite.Text;
string webtel = txtwebtel.Text;
string webcopyright = txtwebcopyright.Text; Response.Write("<script>alert('" + webname + "');</script>");
try
{
SqlConnection con = db.createcon();
con.Open();
SqlCommand com = new SqlCommand("update fw_config set webname='"+webname+"',website='"+website+"',webtel='"+webtel+"',webcopyright='"+webcopyright+"'", con);
com.ExecuteNonQuery();
com.Dispose();
con.Close();
Response.Write("<script>alert('修改完成!');location='config.aspx';</script>");
}
catch (Exception)
{
Response.Write("<script>alert('异常错误,更新失败!');</script>");
Response.End();
} }
解决方案 »
- 我想在.NET页面上放个视频播放器,不知道哪种播放器好些?
- 验证码图片不显示。
- asp.net管理httprequest队列的好方法
- 匹配,匹配
- asp.net2003 IHttpModule 运行错误
- 有个比较新的问题关于c#解析自定义公式的问题
- **各位高手走过路过不要错过,你们微不足道的一个帮助,或许能帮助一位年轻的新手**谢谢了
- 关于使用Session的问题,大家来抢分啊!(ASP。NET)
- 小调查:30岁以下的程序员,谁有女朋友?
- 求救,一个关于日期类型的奇怪问题!
- 研究3天了可还是没有弄明白?用ajax动态生成一个xml文件,然后将其数据保存到数据库中实现那种论坛的发帖的功能大家近来看看,近者有分!
- 关于转向Login.aspx的问题?
{
try
{
SqlConnection con = db.createcon();
con.Open();
SqlCommand com = new SqlCommand("select webname,website,webtel,webcopyright from fw_config", con);
SqlDataReader dr= com.ExecuteReader();
dr.Read();
this.txtwebname.Text = dr.GetValue(0).ToString();
this.txtwebsite.Text = dr.GetValue(1).ToString();
this.txtwebtel.Text = dr.GetValue(2).ToString();
this.txtwebcopyright.Text = dr.GetValue(3).ToString();
dr.Close();
com.Dispose();
con.Close();
}
catch (Exception)
{
Response.Write("<script>alert('提取数据错误!');</script>");
Response.End();
}}
加上!ispostback 可以防止對頁面重新初始化~~~---
lz可以單步調試一下~~看看執行順序~
{}
少了这个