Problem
You know it’s possible to have controls with the same name on one page. In this case Request.Form[”txtSomeText”] returns the values form all 5 textboxes comma separted. (For example: text1,text2, text3.text4, text5).
Example:
..... <input type="text" name="txtSomeText" /> <input type="text" name="txtSomeText" /> <input type="text" name="txtSomeText" /> <input type="text" name="txtSomeText" /> <input type="text" name="txtSomeText" /> .......
The question iin this case is “How to get the values for each textbox?”.
You can say “I’ll split the values…” but it’s not a good solution. What if one of the values is “text,text,text”?
I spent a lot of time splitting strings and searching for workaround of “comma values” (a,b,c) until I found the solution. Here it is..
Solution:
It’s simple: Request.Form returns NameValueCollection. GetValues is a NameValueCollection class method which gives us the requested result.
Request.Form.GetValues(”txtSomeText”) returns a string array with all the values.
asp.net, comma separated values, fields, form, request same name







Hi Vesy,
I am a newbie to .NET was looking for something like this. Your blog is great also got to learn some new things. May be you could help me more with all the tips and tricks. If you could give me your email id it would be great would like to learn new things in .NET, my Email Id: kunu_sid@yahoo.com.
Thanks and Regards
Kunal Sidhpura
hi
clear and concise solution.
Thanks for posting. really helpful!
cheers,
kalyan