How do I determine the Params
sent by 开发者_StackOverflowa POST
method?
If I have a button
, and that button
is clicked, what is sent to the server?
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;
You may take a look at the Params property.
精彩评论