2009-12-07 78 views
1

如何确定POST方法发送的Params回传剖析

如果我有一个button,并单击button什么发送到服务器?

回答

3

如果枚举Request.Form,您将看到POST发送的所有数据。

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

但是,如果您使用的是ASP.NET服务器控件,则不应以此方式访问数据。您应该访问该控件的相关属性。例如

// For a TextBox 
TextBox1.Value; 

// For a DropDownList 
DropDownList1.SelectedIndex; 
DropDownList1.SelectedItem; 
DropDownList1.SelectedValue; 
0

您可以查看Params属性。