itemlist[loc] = new product(codes,size,descrip,color,olditem + 1,url)}
    else // new item
    {olditem =  itemlist[item_num].quan
    itemlist[item_num] = new product(codes,size,descrip,color,olditem + 1,url);
    
    items_ordered = item_num
    item_num = item_num + 1
     }

The above code is in javascript.
the value of 'itemlist' is set whenever i click on additem in different html pages. I want to pass this itemlist values to default.aspx.cs so that it can display a confirmation page with all these values. Can you tell me what code i have to use in default.aspx.cs
I tried using hidden variable in the html page which had the above java script n pass the hidden value to default.aspx.cs. But this did not work out for me.

I haven't done specific research into this, but in my experience the only things that get sent back to the server are form data. This will be any form inputs (text boxes, etc.) and the Viewstate (which is just a form variable of controls with viewstate enabled anyway.) This means you probably will need to send it back as form data, and you won't be able to send the objects back in their objects shape. I would create a hidden text input, sets its value using javascript tricks to convert your array to a string, and then process it as normal form input in the codebehind at the server. Hope this helps.


As alternatives, you might look at ajax (basically partial page form postbacks) or even cookies. You might write this data to a cookie, then you can analyze it at the server, but watch out for restrictions on cookie size, plus some people might just have it turned off.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.