这个Url.Action代码的正确剃刀语法是什么?

时间:2012-02-17 22:36:50

标签: asp.net-mvc-3 syntax razor

鉴于以下代码,正确的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");
    });

1 个答案:

答案 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");
});