If you are trying to use the HTML Helper RenderPartial and you received the following error:
CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments error
do worry, you are not alone. When I was trying to upgrade DimeCasts.Net to Preview 5 I was getting this error. What was really odd, was that the exception and stack trace did not really make sense. It was not till I read Brad Wilson's blog did I realize what the issue was.
Take a look at the following code:
<%= Html.RenderPartial("somecontrol.ascx", SomeDataEntity ) %>
What you will notice is that the code above has an = sign in the markup. I left this because I converted this code from Html.RenderUserControl which needed the '=' as it returned a string. Since RenderPartial is void method you do NOT NEED the '='.
Try removing the '=' sign and see if your issue goes away.
The correct code would be:
<% Html.RenderPartial("somecontrol.ascx", SomeDataEntity ) %>
Hope this helps someone else.
Till next time,
[----- Remember to check out DimeCasts.Net -----]
08-30-2008 1:45 PM