Tuesday, July 26, 2016

Rendering a Partial View in ASP.NET MVC

If you look for documentation regarding rendering a Partial View in ASP.NET MVC, unfortunately, most of the links will point to StackOverflow forum threads.

This becomes a mixed bag of answers, so it may take numerous threads before you discover the right solution!

If you just type @Html.RenderPartial, then you will end up with the following error in Visual Studio:


Since so many Html Helpers just work this way, the actual answer to using the RenderPartial Html Helper is a bit more elusive:

As you can tell from the code sample, the RenderPartial Html Helper needs to be surrounded by curly braces ({...}). After you do this, your RenderPartial Html Helper will work correctly!

No comments:

Post a Comment