一、接收用get 方法传输的数据的写法:
- protected void Page_Load(object sender, EventArgs e)
- {
- string id = Request.QueryString["name"];
- string website = Request.QueryString["website"];
- Response.Write(id + "< br>" + website);
- Response.Write("你使用的是" + Request.RequestType + "方式传送数据");
- }
二、接收用post 方法传输的数据的写法:
- protected void Page_Load(object sender, EventArgs e)
- {
- string id2 = Request.Form["name2"];
- string website2 = Request.Form["website2"];
- Response.Write(id2 + "< br>" + website2);
- Response.Write("你使用的是" + Request.RequestType + "方式传送数据");
- }
- string id4 = Request["name4"];
- string website4 = Request["website4"];
- Response.Write(id4 + "< br>" + website4);
三、同时接受get和post 方法传送数据的代码写法:
A 写法
- string id3 = Request.Params["name3"];
- string website3 = Request.Params["website3"];
- Response.Write(id3 + "< br>" + website3);
B 写法
- string id4 = Request["name4"];
- string website4 = Request["website4"];
- Response.Write(id4 + "< br>" + website4);
$.ajax({
type:"GET/POST"
data:{id:"11"},
url:"aa.aspx",
async:false,
success:function(data){.......}
})
一定要分清楚ajax提交的方式。