c# - Getting TextBox value from another page -


possible duplicate:
asp.net pass value next page

i requesting quantity user using text box , after doing calculations it, want display result on label on page.

here code 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 code 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 may wrong or suggestions on how can it?

you need cast integer type calculations.

 if(session["textbox1value"]!=null)  {    string strquantity = session["textbox1value"].tostring();    int quantity=convert.toint32(strquantity);    //now can use quantity calculations  } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -