2

I have a list of textboxes as an array created using jQuery

<input type="text" name="salaries[]" value="100,000">
<input type="text" name="salaries[]" value="200,000">
<input type="text" name="salaries[]" value="300,000">
<input type="text" name="salaries[]" value="400,000">

Now in C# :

Request.Form["salaries[]"] gives salaries[] = 100,000,200,000,300,000,400,000 Now I am unable to split the values as the commas get mixed up How can this split be achieved?

2
  • cant you just remove the commas on the values you initially pass, then use String.Split Commented Oct 26, 2010 at 22:54
  • How can I remove the values before postback? any ideas?? Commented Oct 27, 2010 at 10:24

1 Answer 1

3

You can't fix it on the server, you have to fix the problem on the client first.

One method is to use unique names for each textbox. ie

<input type="text" name="salaries[0]" value="100,000">
<input type="text" name="salaries[1]" value="200,000">
<input type="text" name="salaries[2]" value="300,000">
<input type="text" name="salaries[3]" value="400,000">

And then (assuming you are using mvc??) the controller will be like this

public void save(String[] salaries) { ...

If not mvc, iterate over all parameters with a name starting with salaries

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.