Pass a Model property as a parameter to an Url.Action

Viewed 5917

I'm developing an ASP.NET MVC 5 app with C# and .NET Framework 4.7.

I'm having troubles trying to pass parameters with Url.Action. When I use this:

<input type="button" value="@Resources.ProductCreateOmitCaption" 
    onclick='location.href=<%: Url.Action("Index", "ProductionOrder", new { isWizard = @Model.IsWizard}) %>' />

I get this:

<input type="button" value="Continue" 
    onclick='location.href=<%: Url.Action("Index", "ProductionOrder", new { isWizard =}) %>' />

I have also tried:

<input type="button" value="@Resources.ProductCreateOmitCaption" 
    onclick="location.href='<%: Url.Action("Index", "ProductionOrder", new { isWizard = @Model.IsWizard}) %>'" />

With this another result:

<input type="button" value="Continue" 
    onclick="location.href='<%: Url.Action("Index", "ProductionOrder", new { isWizard = False}) %>'" />

With the error:

JavaScript critical error at line 177, column 60 in http://AnotherPC:53827/Products/Create\n\nSCRIPT1015: Unfinished string constant

How can I do it?

By the way I'm using Razor.

2 Answers
Related