views:

709

answers:

2

I'm trying to present the user with a list of links (properties: Title, url, visible, order). The list will display based upon their order. The user will be able to drag these into the order they want, which will update the records in the database. The user could also click a button that will sort based on the Title of the link (the text on the list item).

I plan on using JQuery sorting for this: http://jqueryui.com/demos/sortable/

However, I'm not sure how to go about saving the order in the database. Should I update the records every time an item is moved, or should I save it all at the end?

I also don't know how to go about the saving. I'm thinking that I would either be using the stop or the update event documented at the aforementioned site. Which do you recommend?

Finally, I'm not sure how I would construct either the body of this event or the C# method signature to make the update (I'd be fine writing the code). Any pointers or help would be appreciated.

+1  A: 

You should have the user click a button for the servers sake.

EDIT:

Create a generic handler and pass your data in with the query string.

ChaosPandion
definitely let the user click a button "save changes" or similar and then send the sorted list back to the server and persist it down to the DB.
Juri
A: 

When you use the sortable, you will have to add a custom handler for the event 'update' which sortable offers, here you will then have to get the order values of item that was moved and those below it, and then update them in the database using an AJAX call.

Dhruva Sagar