Populating a ListBox with Javascript without Losing Values on Postback
<p>I would like to know which is the best way to do this: I have a form using ASP that is being validated firstly on client-side with jQuery.I have 2 listboxes and  alot of dynamically created buttons on the page.I was successful to get the text of the buttons and write it on the listboxes.However when i try to loop through listboxitems on the server side,i lost the values which was sent to listboxes by jquery and i couldnt get the values in the serverside.I checked it in the forums hiddenfiled would be an option but i couldnt do it,can you please help below is my code.  </p>

<pre><code>    &lt;asp:ListBox ID="ListBox2" runat="server" Width="111px"&gt;&lt;/asp:ListBox&gt;


        $(function () {
            $('.btnplant').toggle(function (e) {
                e.preventDefault();
                var value = $(this).val();
                $(this).css('background-color', '#6FA478');
                $("[id$=ListBox2]").append('&lt;option value="' + value + '"&gt;' + value + '&lt;/option&gt;');
            }, function (e) {
                e.preventDefault();
                var value = $(this).val();
                $(this).css('background-color', '');
                $('[id$=ListBox2] option[value="' + value + '"]').remove()
            });
        });



            string strPlants = string.Empty;
            foreach (ListItem li in ListBox2.Items)
            {
                if (!li.Selected)
                {
                    strPlants += "," + li.Value + ",";
                }
            }
</code></pre>
