C# 当我使用.net图表在页面上显示图片时,它只显示一个页面
您好,我正在Mvc3应用程序中使用图表控件 控制器代码:C# 当我使用.net图表在页面上显示图片时,它只显示一个页面,c#,asp.net-mvc,charts,C#,Asp.net Mvc,Charts,您好,我正在Mvc3应用程序中使用图表控件 控制器代码: Chart newChart = new Chart(800,600); newChart.AddSeries(...) newChart.AddSeries(...) ViewBag.chart = newChart; return View(); 查看页面 @{ Layout = "~/Shared/_Layout.cshtml"} @ViewBag.chart.Write() ... 但是,页面仅显示图表本身,css不起作用,
Chart newChart = new Chart(800,600);
newChart.AddSeries(...)
newChart.AddSeries(...)
ViewBag.chart = newChart;
return View();
查看页面
@{ Layout = "~/Shared/_Layout.cshtml"}
@ViewBag.chart.Write()
...
但是,页面仅显示图表本身,css不起作用,页面中的内容全部丢失。您需要:
- 仅呈现图表的操作(代码似乎是实现此操作的一种方法-
)-例如控制器“ChartController”操作“MyChart” 执行此操作的常用方法是调用chart.Write()
图表。从无效操作方法写入
,或将图表数据保存在字节数组或内存流中,然后从图表操作方法返回
文件结果
- 具有img的视图,其源是呈现图表的操作的url,例如
... <img asrc="@Url.Action("MyChart", "ChartController")" ... /> ...
。。。 ...