开发者

Url.Action is throwing error CS1026: ) expected

开发者 https://www.devze.com 2023-02-01 01:46 出处:网络
开发者_开发百科This is hopefully just a syntax error as I\'m new to MVC and trying to edit something that already exists without having much experience. Having spent ages trying different syntax I\'m
开发者_开发百科

This is hopefully just a syntax error as I'm new to MVC and trying to edit something that already exists without having much experience. Having spent ages trying different syntax I'm obviously missing something.

My issue is that I have this:

var url = '<%= Url.Action("List") %>?page=' + pageNo;

which is fine, but its not passing in all the required parameters as part of pager functionality.

What I want to use is something like:

var url = '<%= Html.RenderAction("List", 
               "PlacementAgreementAgencyPlacementAgreementsPlacement", 
               new { Domain = "Placement", 
                     Id = Model.Item.PlacementAgreement.PlacementAgreementId, 
                     agencyPlacementAgreementId = Model.Item.AgencyPlacementAgreementId, 
                     Page = Model.PageNo 
                }); 
           %>';

But it always complains about error CS1026: ) expected

Same with trying

<%= Url.Action("List", "PlacementAgreementAgencyPlacementAgreementsPlacement", 
        new { Domain = "Placement", 
              Id = ViewData.Model.AgencyPlacementAgreement.PlacementAgreement.PlacementAgreementId, 
              agencyPlacementAgreementId = ViewData.Model.AgencyPlacementAgreement.AgencyPlacementAgreementId, 
              Page = Model.PageNo }
    )%>

If someone could point out what I'm doing wrong that would be great. Basically I'm trying to call controller PlacementAgreementAgencyPlacementAgreementsPlacement with action List passing in all parameters Id, agencyPlacementAgreementId and Page. It's being done in javascript so that I can use this:

    function loadAgreementPlacementPage(pageNo) {

        var url = '<%= Url.Action("List") %>?page=' + pageNo;
        $.get(url, function(data) {
            $("#agreementplacement_list_holder").html(data);
        });

Thanks!!!

PS. Using MVC 1.0.


It should be:

var url = '<%= Url.Action(
               "List", 
               "PlacementAgreementAgencyPlacementAgreementsPlacement", 
               new { 
                   Domain = "Placement", 
                   Id = Model.Item.PlacementAgreement.PlacementAgreementId, 
                   agencyPlacementAgreementId = Model.Item.AgencyPlacementAgreementId, 
                   Page = Model.PageNo 
               }) %>';

Use Url.Action instead of Html.RenderAction and remove the semicolon at the end.


Remove the semicolon before the closing tag

0

精彩评论

暂无评论...
验证码 换一张
取 消