views:

41

answers:

2

How do I determine the Params sent by a POST method?

If I have a button, and that button is clicked, what is sent to the server?

A: 

You may take a look at the Params property.

Darin Dimitrov
+2  A: 

If you enumerate the Request.Form you will see all the data sent by the POST.

protected void Page_Load(object sender, EventArgs e)
{
    foreach (string key in Request.Form.AllKeys)
    {
         Response.Write(key + " :: " + Request.Form[key] + "<br/>");
    }
}

However, you should not access the data this way if you are using ASP.NET Server Controls. You should access the relevant property of that control. e.g.

// For a TextBox
TextBox1.Value; 

// For a DropDownList
DropDownList1.SelectedIndex;
DropDownList1.SelectedItem;
DropDownList1.SelectedValue;
Greg B