MSChart 和 ASP.NET MVC 部分视图
我目前正在尝试将 MSChart 添加到 ASP.NET MVC RTM 中的部分视图。 我查看了以下博客 entry,我目前正在研究选项 B。如果我将代码放在视图 (ASPX) 页面中,它就可以正常工作,但是当我复制确切的代码时将代码写入部分视图(ASCX)时,我得到以下解释:“CS1502:“System.IO.TextWriter.Write(char)”的最佳重载方法匹配有一些无效参数 “。还有其他人遇到过这个问题并解决了这个问题吗?或者他们知道为什么不能将此策略与 MSChart 和 MVC 一起使用吗?
我的代码正是链接文章中选项 B 中的内容。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定问题是什么,但该错误的最常见原因是您在“<%= %>”内使用了语句 块而不是表达式。 由于代码内有“<%= %>” 块放置在对 System.IO.TextWriter.Write 的调用中,它必须是一个表达式。 语句必须包含在“<% %>”内 块,而不是“<%= %>”。
如果您引用的代码在“常规”视图上运行,则它应该可以在部分视图上正常工作。 确保对 RenderPartial 的调用位于“<% %>”中 阻止,因为 RenderPartial 实际上并不返回任何内容,它直接就地进行渲染。
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 becauseRenderPartial
does not actually return anything, it does the rendering directly in place.