2009-12-07 76 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屬性。