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?

2

1 Answer 1

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>");
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.