I am getting below error in render partial in razor code, Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code.
@if (Model.Count() > 0)
{
<div id="mReserveForTodayPartial">
@{Html.Partial("UpdateReserveForToday.mobile");}
</div>
}
kindly help..!
Below code should resolve this issue.
As Razor view engine can parse the code if the statements are available with in "@{ }", So in your code "@{}" is present at "If" statement so its not required to specify again.
Html.Partial()
returnMvcHtmlString
so you have to do like this:in
Html.RenderPartial()
case it writes to the output stream and that's why it's return type isvoid
, so when usingHtml.RenderPartial()
you have to do this:try this code:
If you have to bind DropDownList then You have to placed this code before Html.BeginForm(..)