I’ve tried a lot of combinations but still getting run time errors:
@{Html.RenderPartial("~/Views/_" + @Model.Id + ".cshtml")};
Is there something obvious I’m getting wrong. I have the Id field in model set correctly but I get syntax errors. Such as:
Compiler Error Message: CS1002: ; expected
You can’t have the semi-colon at the end. Edit: You actually need it right after the call of the RenderPartial because you are using curly braces. Also, you do not need the @ for the Model. You also do not need the .cshtml.
I’m also a little worried of how you are using the Model’s ID for the name of the partial view. Be sure to check your paths and the names of your partial views.
You may want it to look something like this:
Check out this too: http://rachelappel.com/razor/partial-views-in-asp-net-mvc-3-w-the-razor-view-engine/