Month: May 2011

  • Multiple Values For The Same GET or POST Parameter in ASP.NET MVC

    Multiple Values For The Same GET or POST Parameter in ASP.NET MVC

    There are situations where you need to pass multiple values for the same parameter to the server, here are some patterns.

    • Multiple checkboxes to pick the values for the same purpose.
      • Select columns to show in the table
      • Select post categories
    • User can add as much values as he/she likes.
      • Add new tag
      • Add language
    • User can remove multiple items from a list.
      • Remove items from shopping cart

    This can be handled by passing many values in one parameter with a common delimiter, or by passing multiple values as the same parameter. Here are examples with the GET method, for the POST it works the same.

    (more…)