1
我有一個帶有按鈕的MVC .cshtml頁面。這是在網格中,我使用jQuery在MVC中打開帶有報表控制器的.aspx頁面
<button type="submit" id="btn_View" name="view"
class="btn_View">
$(".btn_View_Question").click(function() {
var json = [];
var obj = {};
var rowID = $(this).closest('tr').attr('id');
obj.RowId= rowID ;
console.log(obj);
json.push(obj)
var responseDetails = JSON.stringify(json);
$.ajax({
url: "/Home/View",
type: "POST",
data: responseDetails,
dataType: "json",
traditional: true,
contentType: "application/json; charset=utf-8",
});
});
在控制器類,我重定向到一個ASPX報告頁面如下
public RedirectResult ViewQuestionnaire(string[] id)
{
var reportParameters = new Dictionary<string, string>();
reportParameters.Add("ID", id[0]);
Session["reportParameters"] = reportParameters;
return Redirect("../Reports/ViewQuestionarie.aspx");
}
aspx頁面是沒有通過行ID控制器加載。當我調試的時候,aspx頁面的page_load也在執行。什麼可能是我在這裏做的錯誤的東西
您的操作方法需要一個字符串值,並且您的ajax代碼正在發送一個數組。你確定這是正確的嗎? – Shyju
對不起。我錯過了編輯該問題的數組部分 – udaya726