How do I use NameValueCollection with array form fields?

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

Anthony Jones

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top