How do I use NameValueCollection with array form fields?

  • Thread starter Thread starter MrNobody
  • Start date Start date
M

MrNobody

I am trying to use NameValueCollection to post to a page using the WebClient
but I am having trouble figuring out how to use it with a form field which
has multiple values for the same name, such as grouped checkboxes or radio
buttons?

the NameValueCollection seems to only accept one value per key, but clearly
I need to send multiple form values or the same key in this situation...
 
MrNobody said:
I am trying to use NameValueCollection to post to a page using the
WebClient
but I am having trouble figuring out how to use it with a form field which
has multiple values for the same name, such as grouped checkboxes or radio
buttons?

the NameValueCollection seems to only accept one value per key, but
clearly
I need to send multiple form values or the same key in this situation...

Basically WebClient makes the common things you might want to do simple.
You are going to need to build the value string yourself in this case and
use UploadString. You may need to use Uri.EscapeDataString on each data
value. You will also need to set the Content Type header to
"application/x-www-form-urlencoded" yourself using webClient.Headers.Add.
 
Back
Top