views:

17

answers:

1

I have a ListView that contains a large collection of rows with textboxes that users can optionally fill out. These textboxes are not databound. When the user clicks "next" i need to iterate over the rows and determine which fields the user has filled out, and then update a sort of "cart" with the data and move to a confirmation page ("you have selected a, g, v, zz, is this correct?" sort of thing).

  1. I can think of two ways to deal with this. The first is, server side, to walk the items in the listview, get the control ID's, save this data to a list, then save it to a database cart table for the next screen to read.

  2. I can use jquery to collect all the values client side, then pass it back to the form in a hidden field and use something like Newton.Json to get the data into a similar list.

What are the tradoffs of these two approaches? And can you think of a better way to do it?

Keep in mind that i'm on a very tight deadline, so need to do the option that i can implement the fastest.

+1  A: 

I would say both are equally fast to implement, at least to me.

Do what you feel most comfortable with, and it looks to me that option 1 is something you know how to do, so that would probably be your choice if time is of essence.

Performance wise the an ajax call in option 2 sends less data compared to the viewstate in option 1.

If the number of fields are not too high, I don't think either solution is a trade-off. It's more a matter of where do you put your logic, and are you comfortable with putting it on the client.

Mikael Svenson
Ok, what bout stability of the Javascript and compatibility across browsers. Obviously, I won't be supporting Lynx or anything here, but should this simple Javascript work across all browsers going back to at least IE6? Possibly even IE5?
Mystere Man
jQuery states IE6+, so not sure if it would work on IE5. You could always write the javascript yourself. IE4 supported xml-http requests, so you should be able to get it to work.. but.. then there's the time issue ;)
Mikael Svenson
I'm not doing asynchronous postback here, no need for it. Just collecting the results and stuffing it in a hidden field for postback processing.
Mystere Man
After reading the above comments, I will suggest to go with the server-side option as it won't have any browser or client-side dependencies and secondly as Mikael stated option 1 looks to be quite known to you so would take less time.May be you can try the client-side option later. :)
Dienekes
Regarding you latest comment:Then client-side approach won't make much difference in request size, so better to go with option 1.
Dienekes
Agree, since it's a normal postback and not async.
Mikael Svenson