[backcolor=rgb(244, 244, 244) !important]protected void Page_Load(object sender, EventArgs e)
{
[backcolor=rgb(244, 244, 244) !important] if (!Page.IsPostBack)
{
[backcolor=rgb(244, 244, 244) !important] if (Request["id"] != null && !string.IsNullOrEmpty(Request["id"].ToString()))
{
[backcolor=rgb(244, 244, 244) !important] Response.Write( GetData(Request["id"].ToString()));
}
[backcolor=rgb(244, 244, 244) !important] }
}
protected string GetData(string id)
[backcolor=rgb(244, 244, 244) !important]{
string str = string.Empty;
[backcolor=rgb(244, 244, 244) !important] switch (id)
{
[backcolor=rgb(244, 244, 244) !important] case "1":
str += "This is Number 1";
[backcolor=rgb(244, 244, 244) !important] break;
case "2":
[backcolor=rgb(244, 244, 244) !important] str += "This is Number 2";
break;
[backcolor=rgb(244, 244, 244) !important] case "3":
str += "This is Number 3";
[backcolor=rgb(244, 244, 244) !important] break;
default:
[backcolor=rgb(244, 244, 244) !important] str += "Warning Other Number!";
break;
[backcolor=rgb(244, 244, 244) !important] }
return str;
[backcolor=rgb(244, 244, 244) !important]}
运行程序,结果如图:
[/url]
用httpwatcher拦截请求信息,当下拉框中选择数字时,可以截取到如下请求信息。
使用$.post方法时的截图:
[url=http://images.cnblogs.com/cnblogs_com/Johnny_Z/201206/201206171415148110.jpg]
通过上图我们可以看到在POST Data里面有参数,说明这是一次POST请求。
在服务器端状态有改变,或者是修改更新某些数据时多用POST请求。
来自群组: java开发组