简体   繁体   中英

can't get value in code-behind after jQuery appends to asp:Listbox

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");
    });
});

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM