2012-12-21 61 views
2

我在想,为什么IsPostBack总是让我失败,并且无法从Request.QueryString获取值。我错过了代码的任何部分?IsPostBack始终= false,request.QueryString为空

我的JS

function BtnCal() 
{ 
    $.post(missingkids_handler, 
     {"Action":"MainAct", "SubAction":"SubAct"}, 
      function(response) 
      { 
       var rtnObj = response.Data; 
       alert(rtnObj); 
       $("#retnTxt").html(rtnObj); 
      }, "json"); 

} 

我处理aspx.cs

protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 

      if (Request.QueryString["Action"] != "" && Request.QueryString["Action"] == "MainAct") 
      { 
       if (Request.QueryString["SubAction"] == "SubAct") 
       { 
        Response.Clear(); 
        Response.Write("Hello Here"); 
        Response.End(); 
       } 
      } 
     } 

很简单,我只是想从handle.aspx返回一个字符串,而JS调用

感谢

+0

为此目的使用.asmx web服务不是更好吗? – whyleee

回答

0

只是一个客人,你使用的是POST而不是GET方法,你的数据不在查询字符串中。尝试使用Request.Form

if (Request.Form["Action"] != "" && Request.Form["Action"] == "MainAct") 
+0

我其实我已经包括在我的JS – user994985

+0

var missingkids_handler =“MissingKids_handle.aspx”; – user994985

0

使用Request.Form而不是Request.QueryString。它可能会帮助你。