简体   繁体   中英

Url.Action Compilation Error : BC30988: Type or 'With' expected

I have code below, I need redirect to an other view page.

    function patrListClick(PAT_ID) {
        window.location.href = '<%: Url.Action("PatrList", "Patr", new { id = "_id_" }) %>'.replace('_id_', PAT_ID);
    }

在此处输入图片说明

Unfortunately, I got compilation error. 在此处输入图片说明

Try this:

function patrListClick(PAT_ID) {
        window.location.href = '<%: Url.Action("PatrList", "Patr", new with { .id = "_id_" }) %>'.replace('_id_', PAT_ID);
    }

Why are you doing it that way,you can sort it by using Url.Action() and concatenating query string parameters this way:

function patrListClick(PAT_ID) {
   window.location.href = '<%: Url.Action("PatrList", "Patr") %>?id='+PAT_ID;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM