各位大侠们,我在做一个留言板的时候遇到了一个问题.. 我的功能是这样的. 用户留言后按preview的button就可以跳转到下一页去看看,然后确定我误之后就再按SEND的button发出去.. 如果有问题的话可以按modify的button跟转回上一页去修改.. 我之前遇到过页面跳转后值保留的问题.. 现在我用的是先把所以 的值放入SESSION里面传到下一页, 如果要修改.就跳转回上一页,再从session里面把值放进每一个textbox里面.. 这一切看来还OK.. 不过现我就发现了一个问题. 就是当我修改的时候, 页面跳回第一页后, 我改了textbox的内容再按preview后, 在第二个页面里的内容却没有改变.. 我debug过我的代码.. 第一页的textbox.text根本没有改变即使我修改的textbox的内容..
顺带提一下, 我之前试过用javascrit:window.history.go(-1)这个来返回上一页. 不过有IE7里面 就不可以保留之前输入的内容.. 但是firefox里面就可以.. 为什么呢??
以下是我的代码.. feedback.aspx 是第一页, feedbackReview.aspx 是第二页..
feedback.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class feedback : System.Web.UI.Page
{
clsPushData push = new clsPushData();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["method"].ToString() == "1")
{
title.Text = Session["title"].ToString();
subject.Text = Session["subject"].ToString();
subject2.Text = Session["subject2"].ToString();
description.Text = Session["content"].ToString();
name.Text = Session["name"].ToString();
email.Text = Session["email"].ToString();
country.Text = Session["country"].ToString();
}
}
protected void preview_Click(object sender, EventArgs e)
{
// Session.Abandon();
Session["title"] = title.Text;
//if (subject.Text == "other")
//{
Session["subject"] = subject.Text;
Session["subject2"] = subject2.Text;
//}
//else
//{ // Session["subject"] = subject.Text;
// Session["subject2"] = subject2.Text;
//}
// Session["content"] = null;
Session["content"] = description.Text;
Session["name"] = name.Text;
Session["email"] = email.Text;
Session["country"] = country.Text;
Response .Redirect ("feedbackReview.aspx");
} }
feedbackReview.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class feedbackReview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
subject.Text = Session["subject"].ToString();
content.Text = Session["content"].ToString();
title.Text = Session["title"].ToString();
name.Text = Session["name"].ToString();
email.Text = Session["email"].ToString();
country.Text = Session["country"].ToString();
} protected void modify_Click(object sender, EventArgs e)
{
Response.Redirect("feedback.aspx?method=1");
}
}谢谢各位....
顺带提一下, 我之前试过用javascrit:window.history.go(-1)这个来返回上一页. 不过有IE7里面 就不可以保留之前输入的内容.. 但是firefox里面就可以.. 为什么呢??
以下是我的代码.. feedback.aspx 是第一页, feedbackReview.aspx 是第二页..
feedback.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class feedback : System.Web.UI.Page
{
clsPushData push = new clsPushData();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["method"].ToString() == "1")
{
title.Text = Session["title"].ToString();
subject.Text = Session["subject"].ToString();
subject2.Text = Session["subject2"].ToString();
description.Text = Session["content"].ToString();
name.Text = Session["name"].ToString();
email.Text = Session["email"].ToString();
country.Text = Session["country"].ToString();
}
}
protected void preview_Click(object sender, EventArgs e)
{
// Session.Abandon();
Session["title"] = title.Text;
//if (subject.Text == "other")
//{
Session["subject"] = subject.Text;
Session["subject2"] = subject2.Text;
//}
//else
//{ // Session["subject"] = subject.Text;
// Session["subject2"] = subject2.Text;
//}
// Session["content"] = null;
Session["content"] = description.Text;
Session["name"] = name.Text;
Session["email"] = email.Text;
Session["country"] = country.Text;
Response .Redirect ("feedbackReview.aspx");
} }
feedbackReview.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class feedbackReview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
subject.Text = Session["subject"].ToString();
content.Text = Session["content"].ToString();
title.Text = Session["title"].ToString();
name.Text = Session["name"].ToString();
email.Text = Session["email"].ToString();
country.Text = Session["country"].ToString();
} protected void modify_Click(object sender, EventArgs e)
{
Response.Redirect("feedback.aspx?method=1");
}
}谢谢各位....
{
放这里
}
这个是我自己的感觉,我也很菜,不知道对不对,看你的了
我最经也做过类似的功能,就是用的这种方法,你可以在存入数据库的时候返回这条纪录的ID号,然后根据这个ID去修改纪录,如果有问题家我QQ:249468903,也许能帮到你
这种方法是好.. 不过.我考虑到如果用户用的不是宽带的话. 数据经常传入数据库再拿出来的话. 可能会很慢.. 所以我还是想做那种点击button后弹出一个window.. window里有个botton是send那就最好了.. 顺带一提.. 我在textbox中的内容带有回车换行.. 但是当传值到下一页时就没有换行.. 这是什么呢?? 是因为session中不支持这样?? 还是? 我应该怎样解决呢??
但是.. 我将feedback.aspx.cs中的page_load里面的代码移到页面上.. 就所以问题都解决了.. 这是为什么呢? 我觉得不会是默认保存时间的问题..