鉴于以下代码,正确的Razor语法是什么?
$('#ShowClosed').click(function () {
var urlString = '@Url.Action("GetWorkOrders", "WorkOrders")?ShowClosed=$("#ShowClosed").valueOf';
alert(urlString);
$("#jqgWorkOrdersList").jqGrid().setGridParam({ url: urlString }).trigger("reloadGrid");
});
警告返回/ website / MyController / MyAction?ShowClosed = $(“#ShowClosed”)。valueOf
编辑:这是正确的代码。
$('#ShowClosed').click(function () {
var urlString = '@Url.Action("GetWorkOrders", "WorkOrders")?ShowClosed=' + $("#ShowClosed").attr("checked");
$("#jqgWorkOrdersList").jqGrid().setGridParam({ url: urlString }).trigger("reloadGrid");
});
答案 0 :(得分:1)
您在字符串中包含了javascript代码..
$('#ShowClosed').click(function () {
var urlString = '@Url.Action("GetWorkOrders", "WorkOrders")?ShowClosed=' + $("#ShowClosed").is(":checked");
alert(urlString);
$("#jqgWorkOrdersList").jqGrid().setGridParam({ url: urlString }).trigger("reloadGrid");
});