1
私はコントローラからjavascriptコードにId値を取得していますが、完全な行値 "reportssql.reportName"が必要です。 javascriptを通してviewにreportNameの値を表示したいとします。ここでコントローラからJavascriptコードに値を取得
はここ
[HttpGet]
public ActionResult ViewReports(int Id, SQLServer_Reports reportssql)
{
context = new Cost();
//Todo get whole row values from ID, right now we have only Report ID
reportssql.reportName = context.SqlServerReportses.Where(x => x.ReportId == Id).Select(x=>x.reportName).FirstOrDefault();
// List<string> report = context.SqlServerReportses.Where(x => x.ReportId == Id).Select(x=>x.reportName).ToList();
return Json(reportssql.reportName, JsonRequestBehavior.AllowGet);
}
は私のjavascript関数
function ViewReport(ID) {
var id = ID;
// alert(ID);// getting value from gridview button and passing to javascript alert
var state = {};
var newUrl = "/Report/ViewReports/";
//var newUrl="@Url.Action("ViewReports", "Report")";
window.history.pushState(state, null, newUrl);
$.ajax({
url: newUrl + ID,
type: "GET",
success: function() {
$('#ViewReports').show();
$('#ShowGrid').hide();
document.getElementById('lbltipAddedComment').innerHTML = 'Report ID = ' + id;
// display Report name here
},
error: function() {
bootbox.alert("Error");
}
});
}
である私のコントローラであり、私はここラベルにIDの値を表示するだけでなく、同様でREPORTNAMEのvlaueを表示したいのです同様に別のラベル。どのようにレポート名を取得するのですか? return Json(reportssql.reportName、JsonRequestBehavior.AllowGet); のjavascript機能です。