I’m building my first ASP.NET MVC application and I am having some troubles with Partial Views.
If I, as an example, want to put a ‘Footer’ as a Partial I create an ‘MVC View User Control’ in ‘/Views/Shared/Footer.ascx’. (I leave it empty for now)
What is the correct way for adding it to my Layout?
I have tried:
<%=Html.RenderPartial('Footer')%>
and:
<%=Html.RenderPartial('~/Views/Shared/Footer.ascx')%>
For each one I get an exception:
‘CS1502: The best overloaded method match for ‘System.IO.TextWriter.Write(char)’ has some invalid arguments’
What is the correct way to deal with partials in ASP.NET MVC?
In this case don’t use the <%= syntax. Just use the <% %> syntax. Then the first form in your examples should work.
For more info, check here: http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html