Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Asp.Net RenderPartial Exception - CS1502

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 -----]


Posted 08-30-2008 1:45 PM by Derik Whittaker
Filed under:

[Advertisement]

Comments

nick berardi wrote re: Asp.Net RenderPartial Exception - CS1502
on 08-30-2008 8:40 PM

thanks you probably just saved me an hour and half my hair.

ASP.NET MVC Preview Release 5 - Nick Berardi’s Coder Journal wrote ASP.NET MVC Preview Release 5 - Nick Berardi&#8217;s Coder Journal
on 08-31-2008 8:53 AM

Pingback from  ASP.NET MVC Preview Release 5 - Nick Berardi&#8217;s Coder Journal

IHateSpaghetti {code} wrote Blog Carnival #2
on 08-31-2008 11:42 AM

ASP.NET A solution for the partial rendering issue: CS1502: The best overloaded method match for &#39;System

Tim Barcz wrote re: Asp.Net RenderPartial Exception - CS1502
on 09-04-2008 10:56 PM

This is going to save me a ton of time when I upgrade our code this weekend.

Dragan Panjkov wrote re: Asp.Net RenderPartial Exception - CS1502
on 09-07-2008 6:04 PM

Let's be precise. Correct code doesn't have to contain .ascx extension at the end, only name of partial view and a semicolon on the end

<% Html.RenderPartial("somecontrol",  SomeDataEntity );  %>

Baldev Rawat wrote re: Asp.Net RenderPartial Exception - CS1502
on 09-21-2008 11:33 AM

Thanks a lot. I was struggling to solve this problem. Your post has saved my lot of time.

Matt Cole wrote re: Asp.Net RenderPartial Exception - CS1502
on 09-30-2008 11:29 AM

A thanks from me too :)

Mahabub Sikder wrote re: Asp.Net RenderPartial Exception - CS1502
on 10-14-2008 10:44 AM

Its really helpful !

Thanks a lot

LuisKarlos wrote re: Asp.Net RenderPartial Exception - CS1502
on 03-09-2009 4:26 PM

Thanks a lot...:)

Austin wrote re: Asp.Net RenderPartial Exception - CS1502
on 03-19-2009 11:57 PM

Thanks!  Saved me lots of time ;)

Anthony wrote re: Asp.Net RenderPartial Exception - CS1502
on 03-25-2009 12:16 AM

Thanks. This is exactly what I ran into. Your blog post was the first result in my google search.

palmore wrote re: Asp.Net RenderPartial Exception - CS1502
on 05-16-2009 2:57 PM

thanx

Jeroen wrote re: Asp.Net RenderPartial Exception - CS1502
on 06-26-2009 11:44 AM

You just saved me the little hair I have left :)

Amir wrote re: Asp.Net RenderPartial Exception - CS1502
on 07-05-2009 4:47 AM

Thanks again.  Same error in Asp MVC 1.0 (fully baked)....

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)