Possible Duplicate:
asp.net pass a value into next page
I am requesting quantity from user using text box and after doing calculations with it, I want to display the result on a label on another page.
Here is the code for confirm.aspx.cs
public partial class confirm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["user"] != null)
{
Label2.Text = Server.HtmlEncode(Request.Cookies["user"]["userName"]);
Label3.Text = Server.HtmlEncode(Request.Cookies["user"]["email"]);
Label1.Text = Server.HtmlEncode(Request.Cookies["user"]["items"]);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.Add("TextBox1Value", TextBox1.Text);
Response.Redirect("total.aspx");
}
}
and here is the code for another page, total.aspx.cs
public partial class total : System.Web.UI.Page
{
int totalprice;
protected void Page_Load(object sender, EventArgs e)
{
//Label1.Text = Server.HtmlEncode(Request.Cookies["confirm"]["quantity"]);
int quantity = Session["TextBox1Value"];
if (Request.Cookies["user"]["items"] == "Tyres")
{
totalprice = 20 * quantity;
Label2.Text = totalprice.ToString();
}
}
}
Anywhere I am may be wrong or any suggestions on how can I do it?