title: Using Webclient to POST/select all the option Values of a Multiselect
body: <p>I am trying to write an application to automate router configuration. Unfortunately with the router we are using, telnet is not an option.</p>
  
  <p>So I have had to interface with the Cisco web interface using C# WebClient class.</p>
  
  <p>Up until now I had been able to set everything I needed using NameValueCollection and WebClient.UploadValues.</p>
  
  <p>I would take all the input elements on the form, then just upload the name value Collection corresponding to the input types on the form, setting the values of each to the desired setting.</p>
  
  <p>But now I have run into a problem.</p>
  
  <p>With one of the forms, it is using a multiselect control to handle an array of input data, not an input type.</p>
  
  <p>I am at a total loss for how to set this.</p>
  
  <p>The html for the multiselect is as follows</p>
  
  <pre><code>&lt;select multiple class="MultiSelect" name="PortRangeList" size="12" onChange="showList(this.form.PortRangeList);" style="width: 100%"&gt;
      &lt;option value="All Traffic{[(*-*-*)]}1;0;1;65535;0}"&gt;All Traffic [TCP&amp;UDP/1~65535]&lt;/option&gt;
      &lt;option value="DNS{[(*-*-*)]}2;17;53;53;0}"&gt;DNS [UDP/53~53]&lt;/option&gt;
      &lt;option value="FTP{[(*-*-*)]}3;6;21;21;0}"&gt;FTP [TCP/21~21]&lt;/option&gt;
      ...
  &lt;/select&gt; 
  </code></pre>
  
  <p>When I was using the input types, I would simply do the following</p>
  
  <pre><code>NameValueCollection formNetworkData = new NameValueCollection();
  formNetworkData["ipAddr"] = "192.168.1.2";
  formNetworkData["lanMask"] = "255.255.255.0";
  downloadedData = _routerWebClient.UploadValues(_routerIP + NETWORK, formNetworkData);
  </code></pre>
  
  <p>But looking at the code for this new form, it appears right before it submits, it selects all the options in the multiselect.</p>
  
  <p>I realize I have probably asked this question poorely, but any assistance would be greatly appreciated.</p>
  
  <hr>
  
  <p>Using Chrome debugger PortRangeList is exactly as you said.</p>
  
  <p>There are 5 input types</p>
  
  <p>submitStatus, upnpOpen (etc...)</p>
  
  <p>For those my code looks like this</p>
  
  <pre><code>NameValueCollection formData = new NameValueCollection();
  formData["submitStatus"]="1";
  formData["upnpOpen"]="0";
  downloadedData = _routerWebClient.UploadValues(SERVICE0, formData);
  </code></pre>
  
  <p>But in order to submit the PortRangeList data, I can't use the NameValueCollection because it does not allow a name to have muliple values.</p>
  
  <p>how could submit that?</p>
  
  <p>WebClient.UploadData, WebClient.UploadFile or WebClient.UploadString maybe?</p>