MSChart and ASP.NET MVC Partial View

I am currently trying to add MSChart to a partial view in ASP.NET MVC RTM. I watched the following blog post , and now I'm studying option B. If I take my code, put it inside the view (ASPX) page, and it works fine, but when I copy the exact code to Partial View (ASCX), I get the following excpetion : "CS1502: the best overloaded method matching for" System.IO.TextWriter.Write (char) "has some invalid arguments" Does anyone else run into this and solve the problem or know why it is not possible to use this strategy with MSChart and MVC?

My code is exactly what is in option B in the related article.

+3
source share
1 answer

I'm not quite sure what the problem is, but the most common cause of this error is because you used the statement inside the "<% =%>" block, not the expression. Since the code inside the block "<% =%>" is placed in the call System.IO.TextWriter.Write, it must be an expression. Statements must be enclosed in blocks "<%%>", not "<% =%>".

The code you referenced should work fine on a partial view if it works on a "normal" view. Make sure the call RenderPartialis in the "<%%>" block, because it RenderPartialactually returns nothing, it does the rendering right there.

+7
source

Source: https://habr.com/ru/post/1706429/


All Articles