mathk
mathk

Reputation: 8133

Razor syntax issue with RenderPartial (CS1501)

The RenderAction is working just fine but as soon as I surround it with a if statement I get a compile error:

@if (@Model.IsConfigurationAllow)
{
    @{ Html.RenderAction("Save"); } // CS1501: No overload for method 'Write' takes 0 arguments
}

More general question where can I found the grammar for the Razor view syntax?

Upvotes: 2

Views: 765

Answers (3)

VJAI
VJAI

Reputation: 32758

Did you try this?

@if (@Model.IsConfigurationAllow)
{
    <text>@{ Html.RenderAction("Save"); }</text>
}

Upvotes: 1

Kaf
Kaf

Reputation: 33809

There are a few below (more can be found just by googling);

Upvotes: 0

Jan
Jan

Reputation: 16032

Html.RenderAction renders the HTML directly into the response, so you cant call it in a code block.

The counterpart Html.Action returns a string with the results.

See http://haacked.com/archive/2009/11/17/aspnetmvc2-render-action.aspx

Upvotes: 3

Related Questions