2015-12-08 26 views
0

使用jQuery ajax發佈我將數組變量發佈到asp.net頁面。但我不能檢索的頁面加載事件數組變量..Jquery將數組數據發佈到asp.net頁面:無法在頁面加載事件中檢索數組

$(document).ready(function() { 
     var importTable = $("#dataTables-example"); 
     var arrayOfValues = []; 
     $('#btnDownload').click(function() { 
      $('input:checkbox:checked', importTable).each(function() { 
       debugger; 
       arrayOfValues.push($(this).closest('tr').find('td:nth-child(2)').text()); 
      }).get(); 

      $.post('CS.aspx', { arrayOfValues: arrayOfValues }, function (data) { }); 
     }); 
    }); 

我的頁面加載事件:

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (IsPostBack) 
    { 
     Response.ContentType = "application/json"; 
     string emptyStringArray = Request.Params["arrayOfValues1"]; 
    } 
} 
+2

Request.Params [「arrayOfValues」] – ssilas777

+2

我覺得你PARAM名稱是「arrayOfValues」而不是「arrayOfValues1」 –

+0

甚至Request.Params變化[「arrayOfValues1」]來Request.Params後,我仍然得到了emptyStringArray空值[ 「arrayOfValues」]。 –

回答

0

的請求變量檢查計數。

+0

我已經解決了這個問題。我不是使用get request和hiddenfield來發布帖子請求。 –

相關問題