Currently, I have a set of textboxes that are dynamically created with the same name
attribute:
<input type="text" name="SameName" value="Value1" />
<input type="text" name="SameName" value="Value2" />
On the server side I am receiving a submitted form (POST) and accessing Request.Form["SameName"]
and the value is Value1,Value2
.
My question is, is it possible to change the delimiter from a comma to a pipe (or some other character) some way?
I can't just replace commas with pipe because I need to delimit the different fields:
<input type="text" name="SameName" value="Val,ue1" />
<input type="text" name="SameName" value="Value2" />
would be:
Val,ue1,Value2
Suggesting I have 3 text fields instead of two. So a simple Replace(',','|')
isn't helpful.
options window by clicking Start -> Settings -> Control Panel -> Regional Settings. separator with the one you want to use (let's say a pipe symbol | ).
If your csv file consists of either pipe/comma separated data then you can go with pipe/comma as delimiter else if it a combined of comma and pipes.
The pipe character separates each field of text. Most delimited files are separated by either a comma or a tab; however, the pipe can also be used. Delimited files can be read and shared across many different platforms, making it an ideal data sharing format. You can import up to 1,048,576 rows and 16,384 columns.
On the Numbers tab (Figure 5), go to the List separator field and click the ▾. Select the pipe delimiter (|) from the options. 6. Click Apply then click OK.
In reality, the POST sends the values of the two inputs individually. You're seeing the concatenated version because of how you're accessing it from Request.Form (which is a NameValueCollection).
To be able to differentiate between the different POSTed values, you can use GetValues()
string[] values = Request.Form.GetValues("SameName");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With