I have an array of javascript objects and I want to press a submit button and ‘send’ them much like I can access a textbox or listbox’s members – ie. the page posts back and I can put some code in the button’s submit method. Is there a way of doing this? Or do I have to put them into a control?
Share
On the button’s submit method, you need to serialize your array of JavaScript objects and assign it to a hidden input. On the server-side you then get that JSON string out of the input and do something with it (e.g. deserialize it).
To serialize, first add a ScriptManager to the page:
Then you can run JavaScript like this: