asp.net mvc - Rendering partial views with Razor in MVC5 -
i'm trying partial view render using razor in mvc5. when use
@{ html.renderpartial("viewname", model); } i parser error:
unexpected "{" after "@" character. 1 time within body of code block (@if {}, @{}, etc.) not need utilize "@{" switch code.
when remove {}, i.e.:
@html.renderpartial("viewname", model); i compilation error
cannot implicitly convert type 'void' 'object'.
what doing wrong?
you haven't posted context of code, error happens when you're using @ straight within code block without html wrappings. example:
@if (true) { @{ html.renderpartial(...); } } would give error, while:
@if (true) { <div> @{ html.renderpartial(...); } </div> } would fine. solve removing code block html.renderpartial entirely, including @:
@if (true) { html.renderpartial(...); } asp.net-mvc razor asp.net-mvc-5
No comments:
Post a Comment