I am trying to pass information between two asp.net page. user select item from check list box and calculate how many time add to cart. could any one told me what is problem with my code?
protected void btnAdd_Click(object sender, EventArgs e)
if(itemListchk.SelectedItem != null)
int totalNumberItems = 0;
foreach (ListItem li in itemListchk.Items)
if (li.Selected == true)
string itemName = itemListchk.SelectedItem.ToString();
string itemValue = itemListchk.SelectedValue.ToString();
HttpCookie cookie = new HttpCookie(itemName, itemValue);
totalNumberItem += Convert.ToInt16(li.Value);
Label1.Text = "You have \ " + totalNumberItems.ToString() + "\ items in your cart ";
Once i did the program of Cookies but i have done it using JSP and Servlet :
in Jsp there is one function - getComment() to retrieve all the data stored inside the cookies
I assume you are referring to a checkbox....
You really don't want to store information in cookies for a few reason:
1) Cookies are expensive -- the entire contents are sent both ways with every request.
2) Cookies are hackable -- unless you are encrypting things in your application everything is sent in the clear.
A much better option for ASP.NET is to use the User Profile, it is baked in and can be made to work with anonomous users as well. If you are rolling your own solution, the better method is to just use an identifier and store the data in a database.