[RESOLVED]Textarea Post Data including colon in text How to Split this?

Hi, I’ve just detected a Problem in my Webmatrix Project and Need help.

My code produces a dynamic amount of textareas by a foreach Loop.
This textarea is named "test_text"

When I submit the form, the Data is fetched by

a variable:
myText = Request["test_text"]

and then splittet into a string[] Array.

string[] a_text = myText.Split(new char[] {‘,’});

This works fine instead the text in the TextBox contains a colon.

"Hello, my Darling how are you?"

So the text would be cut off after Hello.

How can I get this text in an Array without being cut off

Thanks for your help

monsee

monsee

Hi, I’ve just detected a Problem in my Webmatrix Project and Need help.

My code produces a dynamic amount of textareas by a foreach Loop.
This textarea is named "test_text"

When I submit the form, the Data is fetched by

a variable:
myText = Request["test_text"]

and then splittet into a string[] Array.

string[] a_text = myText.Split(new char[] {‘,’});

This works fine instead the text in the TextBox contains a colon.

"Hello, my Darling how are you?"

So the text would be cut off after Hello.

How can I get this text in an Array without being cut off

Thanks for your help

monsee

Hey monsee!

Your code is designed to split where the comma is – If you do not wish to apply the Split, simply remove that code?

I am only guessing but I am not entirely sure what you want to achieve.

Cheers!

Hi,

my Intension was to Build an Array of multiline-text-fields which worked fine until I wrote a text that conatined a "," colon.
So the Split-Function splits the text where it shouldn’t do this.

For example: There are 2 textareas both named test_text. Their Content will be posted as a comma separated string:

[text1 From test_text], [text2 From test_text]

Lets assume the Content of one of theese textareas contains text wit a colon:

[Hello Mom, How are you?], [text2 From test_text]

Although there are only 2 textareas the split function would create an Array with size of 3.

Well, never the less I’ve just found the answer by myself:

I had to create the Name of the textareas dynamically, too, like so:

var i = 0;
while(i < 1)
{
<textarea Name="test_text_@i">Some text</textarea>
}

Using this way there’s no more need to Split the data into an Array.

So please see my request as answered or solved.

thanks in advance

monsee

Leave a Reply