locked
advanced handling POST data (POSTING ARRAYS) RRS feed

  • Question

  • User-1716255607 posted

    ok I have form on page and with jquery ajaxx I send POST data to ashx handler like this

    $.post("/getData.ashx?a=send, $("form").serialize(), function(responseText, textStatus) {...

    I have multiple input with same name so they act like arrays which is exactly what I need but when I get data in context.Response.form

    arrays are separated with "," and if someone enters "," in input there comes ofc to error because I don't have array with 3 fields but with more fields (depends how many "," user wrote in input...) and then I can't get value of inputs... putting other names for input isn't an option... any suggestion?

    Wednesday, September 2, 2009 6:46 AM

Answers

  • User863160722 posted

    Try replacing Request.Form["name"] with Request.Form.GetValues("name") - the first will return all posted values concatenated with commas; the second will return the values as an array.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 2, 2009 10:33 AM

All replies

  • User679358827 posted

    Off the top of my head, I'd suggest using a Javasscript event to detect when text has been changed in the input control and then escape any Comma's you can find.

    Alternatively, what if you make sure that the content of each Input gets put inside a pair of "'s before the serialization takes place ?

    Wednesday, September 2, 2009 7:55 AM
  • User-1716255607 posted

    I thought about that, but I don't like idea that I solve these things on clientside...

    hmm, I wanted to override function that serialize html arrays and seperate them with "," but dunno where this function is...

    well if nothing else come up I'll have to change "," on clientside....

    any other suggestion?


    Wednesday, September 2, 2009 9:07 AM
  • User863160722 posted

    Try replacing Request.Form["name"] with Request.Form.GetValues("name") - the first will return all posted values concatenated with commas; the second will return the values as an array.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 2, 2009 10:33 AM
  • User-1716255607 posted

    yep that's it thank you :) I can't belive how I miss that...

    Thursday, September 3, 2009 1:14 AM