Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pipe delimit forms encoded values instead of commas?

Tags:

c#

.net

asp.net

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.

like image 373
marteljn Avatar asked Feb 21 '13 21:02

marteljn


People also ask

How do you change a comma separated to a pipe separated?

options window by clicking Start -> Settings -> Control Panel -> Regional Settings. separator with the one you want to use (let's say a pipe symbol | ).

Can you have a pipe delimited CSV?

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.

What is pipe delimited format?

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.

How do I change from separator to pipe in Windows 10?

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.


1 Answers

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");
like image 131
voithos Avatar answered Nov 07 '22 02:11

voithos