I'm using two related listboxes to transfer data from one list to another. In my backend, when I reference Request.Form["lstAssociated"] I can get a list of the id's from the listbox that contains the item I selected to send to the other list, however, I don't see anywhere in the data how I can obtain the ID of just the item I have selected. We are using Razor forms.
Hi Danielle,
The selected state is solely visual. We highlight the dom element using CSS.
If I understand correctly, you would like to know which elements moved from one listbox to another. Please correct me if I am wrong.
Is it an option to compare the previous state of the listboxes before the user modified them to the submitted data, hence obtaining the relocated items?
Yes, I supposed I could, I just assumed there would be an event I could tie into which would contain the information of the item being moved. If not, I will code something like you have described.
Thanks for your help.
Hi Danielle,
Another option you have is to store the ids of items that change position in a hidden input and then extract the ids from the payload of the request.
You could get the id of the element that changed position and store it in a hidden input within the Add/Remove event handlers.
e.g.
// listbox config .Events(events => events .Add("onAdd") .Remove("onRemove") ) function onRemove(e) { // e.items is an array that contains all removed items // store the ids of removed items here }