views:

1340

answers:

2

I'm currently trying to add an MSChart to a partial view in ASP.NET MVC RTM. I have reviewed the following blog entry, and I'm currently investigating Option B. If I take my code an place it inside a View (ASPX) Page and it works fine, but when I copy the exact code into a Partial View (ASCX) I get the following excpetion: "CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments ". Has anyone else run into this and solved the issue or do they know why it's impossible to use this strategy with MSChart and MVC?

My code is exactly what's in option B on the linked article.

+6  A: 

I'm not exactly sure what the problem is, but the most common cause of that error is that you've used a statement inside a "<%= %>" block rather than an expression. Since the code within a "<%= %>" block is placed within a call to System.IO.TextWriter.Write, it must be an expression. Statements must be enclosed within "<% %>" blocks, rather than "<%= %>".

The code you referenced should be working just fine on a partial view, if it runs on a "regular" view. Make sure that the call to RenderPartial is in a "<% %>" block because RenderPartial does not actually return anything, it does the rendering directly in place.

anurse
I was so focused on the MSChart portion of the code that I never investigated the more basic components, thanks for shedding light on this. +1 (wish I could do more)
JPrescottSanders
No problem! Glad that fixed your problem!
anurse
+3  A: 

Thaaaaaaaaaaaaaaaaaaank You