0

I am trying to render a partial view, I am getting no errors or issues other than the graph just no displaying.

Main View

@{Html.RenderPartial("~/Views/Shared/Charts/LineChart.cshtml", Model);}

Partial View

@model IEnumerable<VW_NewVulnerabilities>

<div class="chart">
    <canvas id="lineChart" style="height:250px"></canvas>
</div>
@section scripts {plenty of js in here }

All of this worked when it was in one view. Essentially i am trying to create a dynamic chartjs line chart so i can pass it a list of information and i can reuse it.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
user1552172
  • 614
  • 1
  • 9
  • 27

1 Answers1

1

You can not use section in partial view, by design, it is the responsibility of the view to set up all the require scripts, not partials.

Having said that, if you want to set script in your partial view, you have to create something like helper to generate, such as this so answer:

Using sections in Editor/Display templates

Community
  • 1
  • 1
Alan Tsai
  • 2,465
  • 1
  • 13
  • 16