开发者

Anatomy of a Postback

开发者 https://www.devze.com 2022-12-13 21:12 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消