Pass list of strings from Javascript to asp.net code-behind
<p>I have problems with javascript in ASP.NET.<br>
I modify a listBox, with add and remove command using javascript.<br>
Now I have to use the data of the list in the code behind. How can I pass this data to the server?  Can I use json?</p>

<p>Here is the code. I can't use hiddenField because of the remove.</p>

<pre><code>&lt;asp:listbox ID="SubCat" runat="server" &gt;&lt;/asp:listbox&gt;
&lt;input type=button onClick="addOption(SubCat)"; value='Add'&gt; 
&lt;input type=button onClick="removeOptions(SubCat)"; value='Remove Selected'&gt;
&lt;input type=button onClick="removeAllOptions(SubCat)"; value='Remove All'&gt;


&lt;script type="text/javascript"&gt;


 function removeAllOptions(selectbox) {
    var i;
    for (i = selectbox.options.length - 1; i &gt;= 0; i--) {
        selectbox.remove(i);
    }
 } 

 function removeOptions(selectbox) {
    var i;
    for (i = selectbox.options.length - 1; i &gt;= 0; i--) {
        if (selectbox.options[i].selected)
           selectbox.remove(i);
    }
 }

 function addOption(selectbox) {
    var txtBox1 = document.getElementById('txForn')
    var optn = document.createElement("OPTION");
    var t = txtBox1.value;
    optn.text = t;
    optn.value = t;
    selectbox.options.add(optn);
 }

&lt;/ script&gt;
</code></pre>
