Reputation: 2908
I've created 2 asp:listbox... asp:ListboxFrom and asp:ListboxTo. When I double click on the item on ListboxFrom it moves (appends) the item to ListboxTo... So everything works fine till here. But when I click on the submit button to process everything I don't get the selected items in my code-behind for the listboxes. I debugged on Page_Init and Page_load but it restores the default controlstate values.... So what am I missing now?
1) How can I get the values in code-behind ? so the state of asp:listbox as it is added client-side code. 2) another question: when it appends to the ListboxTo the items are selected per default (they are blue). How can I avoid this?
thanks for helping,
below is the simple JQuery code I use in aspx,
<asp:ListBox ID="listboxFrom" SelectionMode="Multiple" />
<asp:ListBox ID="listboxTo" SelectionMode="Multiple" />
$(function() {
$('select[id$=dnn_ctr658_ViewAgenda_Invoer_listboxFrom]').bind("dblclick", function() {
$("select[id$=dnn_ctr658_ViewAgenda_Invoer_listboxFrom] option:selected").appendTo("#dnn_ctr658_ViewAgenda_Invoer_listboxTo");
});
$('select[id$=dnn_ctr658_ViewAgenda_Invoer_listboxTo]').bind("dblclick", function() {
$("select[id$=dnn_ctr658_ViewAgenda_Invoer_listboxTo] option:selected").appendTo("#dnn_ctr658_ViewAgenda_Invoer_listboxFrom");
});
});
Upvotes: 1
Views: 2123
Reputation: 8407
This is a security thing. I wonder why aspnet doesn´t throw a warning exception for an unauthorized element manipulation...
You will have to create either a custom element or u use a hiddenfield. But please be very carefull with data, lists that everybody can change on client side. Everybody could insert items in your dropdown and make it selected...
Upvotes: 1