我有一些文本框。用户需要键入文本框中的数据。完成后,他们会点击提交按钮。然后,它将被定向到“review.aspx”页面。在review.aspx页面中,页面将在标签的前一页中显示它们插入的数据。这里有人知道怎么做吗?谢谢。
这是我停止的地方
protected void Button2_Click(object sender, EventArgs e)
{
Session["brand"] = DropDownList1.SelectedItem.Text;
Session["model"] = TextBox1.Text;
Session["plate"] = TextBox2.Text;
Session["color"] = TextBox3.Text;
Session["year"] = TextBox4.Text;
Session["service"] = TextBox5.Text;
Response.Redirect "Review.aspx";
如何捕获要在评论页面中显示的会话。我用标签显示它。
答案 0 :(得分:1)
会话数据类型是对象,我们必须将其转换为String类型,以便我们可以将其存储在字符串变量中。
string brand = Session["brand"].ToString();
string model =(string) Session["model"];
string plate =(string) Session["plate"];
string color =(string) Session["color"];
string year =(string) Session["year"];
string service =(string) Session["service"];
将标签文本属性设置为等于这些变量
Label1.Text = brand+""+model+""+plate+""+year+""+service;
答案 1 :(得分:1)
以下列方式将会话[“ID”]对象转换为字符串:
string brand=Session["brand"].ToString();
string model=Session["model"].ToString();
string plate=Session["plate"].ToString();
string color=Session["color"].ToString();
string year=Session["year"].ToString();
string service=Session["service"].ToString();
并设置相应标签中的值:
lblBrand.Text=brand;
lblModel.Text=model;
lblPlate.Text=plate;
lblColor.Text=color;
lblYear.Text=year;
lblService.Text=service;
答案 2 :(得分:1)
如何使用会话在其他页面上显示数据(初学者样本)
第1步:采取两个webform webform1& webform2。
第二步:拖动一个短信箱& webform1&上的一个按钮在按钮单击事件中编写以下代码 -
Session["name"] = TextBox1.Text;
Response.Redirect("webform2.aspx");
第3步:在webform2上拖动标签&在此页面的页面加载事件中编写以下代码(即:webform2)。
Label1.Text = Session["name"].ToString();
结论:在webform1上输入文本框的名称/数据将显示在下一页上。