0

I am a PHP programmer, need some code to do in C#.net a reporting tool.

I am sending this form to ASP.NET

<input type="text" name="para[a]" value="A">
<input type="text" name="para[b]" value="B">

in PHP I am able to get these values by a simple loop

if(isset($_POST['para'])){
   foreach($_POST['para'] as $key => $val){
        echo 'Name '.$key.', Value = '.$val;
   }
}

but in C#.net I am unable to do anything like this, I googled but no reference is found

for (int i = 0; i < keys.Length; i++)
{
    Response.Write(keys[i] + ": " + Request.Form[keys[i]] + "<br>");
}

This C# code telling me all keys, but not as an form of array.

Any help?

Grokify
  • 13,266
  • 6
  • 50
  • 73

1 Answers1

1

Get a subset of keys that begin with your specific prefix. Or filter out the keys that don't begin with the prefix.

for (int i = 0; i < keys.Length; i++)
{
    if (keys[i].StartsWith("para") {
        Response.Write(keys[i] + ": " + Request.Form[keys[i]] + "<br>");
    }
}
PepitoSh
  • 1,765
  • 14
  • 13