閱讀532 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Asp.net中jquery的ajax請求頁麵獲取參數的注意點

 ASP.net中get和post提交方式,利用request參數的方式是不同的。

 

一、接收用get 方法傳輸的數據的寫法:

  1. protected void Page_Load(object sender, EventArgs e)  
  2.     {  
  3.         string id = Request.QueryString["name"];  
  4.         string website = Request.QueryString["website"];  
  5.         Response.Write(id + "< br>" + website);  
  6.  
  7.       Response.Write("你使用的是" + Request.RequestType + "方式傳送數據");  
  8.  
  9.     }  
  10.  

 

二、接收用post 方法傳輸的數據的寫法:

  1. protected void Page_Load(object sender, EventArgs e)  
  2.     {  
  3.         
  4.         string id2 = Request.Form["name2"];  
  5.         string website2 = Request.Form["website2"];  
  6.         Response.Write(id2 + "< br>" + website2);  
  7.  
  8.  
  9.         Response.Write("你使用的是" + Request.RequestType + "方式傳送數據");  
  10.  
  11.     }  
  12.  
  13.        string id4 = Request["name4"];  
  14.         string website4 = Request["website4"];  
  15.         Response.Write(id4 + "< br>" + website4);  
  16.  

 

三、同時接受get和post 方法傳送數據的代碼寫法:

A 寫法

  1.        string id3 = Request.Params["name3"];  
  2.         string website3 = Request.Params["website3"];  
  3.         Response.Write(id3 + "< br>" + website3);  
  4.  

B 寫法

  1.        string id4 = Request["name4"];  
  2.         string website4 = Request["website4"];  
  3.         Response.Write(id4 + "< br>" + website4);  

 

 

$.ajax({
         type:"GET/POST"
          data:{id:"11"},
          url:"aa.aspx",
          async:false,
          success:function(data){.......}

 })

一定要分清楚ajax提交的方式。

最後更新:2017-04-02 06:52:22

  上一篇:go Spring事務配置的五種方式
  下一篇:go 同步/異步 阻塞/非阻塞 .