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?
我目前正在尝试将一个MSChart添加到ASP.NET MVC RTM中的部分视图中。我已经查看了以下博客条目,我正在调查选项B.如果我将我的代码放在View(ASPX)页面中并且它工作正常,但是当我将确切的代码复制到Partial View(ASCX)时)我得到以下激发:“CS1502:'System.IO.TextWriter.Write(char)'的最佳重载方法匹配'有一些无效的参数”。有没有其他人遇到这个并解决了这个问题,或者他们知道为什么不可能在MSChart和MVC上使用这个策略?
My code is exactly what's in option B on the linked article.
我的代码正是链接文章中选项B的内容。
1 个解决方案
#1
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 "<%= %>".
我不确定问题是什么,但是该错误的最常见原因是您在“<%=%>”块中使用了一个语句而不是表达式。由于“<%=%>”块中的代码放在对System.IO.TextWriter.Write的调用中,因此它必须是表达式。语句必须包含在“<%%>”块中,而不是“<%=%>”。
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.
如果它在“常规”视图上运行,那么您引用的代码应该在部分视图上正常工作。确保对RenderPartial的调用位于“<%%>”块中,因为RenderPartial实际上没有返回任何内容,它会直接进行渲染。
#1
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 "<%= %>".
我不确定问题是什么,但是该错误的最常见原因是您在“<%=%>”块中使用了一个语句而不是表达式。由于“<%=%>”块中的代码放在对System.IO.TextWriter.Write的调用中,因此它必须是表达式。语句必须包含在“<%%>”块中,而不是“<%=%>”。
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.
如果它在“常规”视图上运行,那么您引用的代码应该在部分视图上正常工作。确保对RenderPartial的调用位于“<%%>”块中,因为RenderPartial实际上没有返回任何内容,它会直接进行渲染。