缺少剃刀布局

时间:2017-02-20 19:04:51

标签: c# asp.net asp.net-mvc-4 razor

为什么此页面不显示布局或ViewBag.Title? “MyChart”呈现正常,但是当调用“Write”函数时,它会用渲染图像替换所有页面内容。有没有办法在渲染图像之后或之前向页面添加更多内容?

@model cmCase.Models.xyz

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

<div class="well">
    @{
        var myChart = new Chart(width: 1000, height: 400, theme: ChartTheme.Green)
            .AddTitle("Most Popular")
            .AddSeries(name: "Employee", xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" },  yValues: new[] { "2", "6", "4", "5", "3" })
            .AddSeries(name: "Employee12", xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" },yValues: new[] { "2", "6", "4", "5", "3" })                    
            .Write();
    }
</div>

1 个答案:

答案 0 :(得分:0)

好的,看起来需要两个步骤。

第一步是创建一个生成图表的页面

第二步是在另一页显示结果图像。

如此处所述using charts in razor