Url.Action抛出错误CS1026:)预期 [英] Url.Action is throwing error CS1026: ) expected

查看:244
本文介绍了Url.Action抛出错误CS1026:)预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是希望只是一个语法错误,因为我是新来的MVC,并试图修改已经存在的,而不必太多经验的东西。已经花了年龄在尝试不同的语法我显然失去了一些东西。

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 
                }); 
           %>';

但它总是抱怨错误CS1026:)预计

But it always complains about error CS1026: ) expected

同样的,试图

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

如果有人能指出我做错了什么,将是巨大的。基本上我试图调用控制器 PlacementAgreementAgencyPlacementAgreementsPlacement 用行动列表传递的所有参数标识,agencyPlacementAgreementId和页面。它在JavaScript正在做,这样我可以用这样的:

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);
        });

谢谢!

PS。使用MVC 1.0。

PS. Using MVC 1.0.

推荐答案

它应该是:

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

使用 Url.Action 而不是 Html.RenderAction 并在末尾删除分号。

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

这篇关于Url.Action抛出错误CS1026:)预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆