2

I Have a Syncfusion control in my view and I want to stop rendring it for one of my ActionResult in controller. How I can stop this from rendering based on the controller call.

<div>
                        @(Html.EJ().Chart("container")
          .PrimaryXAxis(pr => pr.Range(ra => ra.Min(0).Max(30).Interval(5)).Title(tl => tl.Text("Days")))
.PrimaryYAxis(pr => pr.Title(tl => tl.Text("Fuel Usage")).Range(ra => ra.Min(ViewBag.ChartMin).Max(ViewBag.ChartMax + 100)).RangePadding(ChartRangePadding.None)
.LabelFormat("{value}").Range(ra => ra.Min(ViewBag.ChartMin).Max(ViewBag.ChartMax + 100)))
          .CommonSeriesOptions(cr => cr.Type(SeriesType.Line).EnableAnimation(true)
          .Marker(mr => mr.Shape(ChartShape.Circle).Size(sz => sz.Height(10).Width(10)).Visible(true)).Border(st => st.Width(2)))
          .Series(sr =>
              {
                  sr.Points(pt =>
                      {
                          pt.X("5").Y(ViewBag.ChartDetails[0]).Add();
                          pt.X("10").Y(ViewBag.ChartDetails[5]).Add();
                          pt.X("15").Y(ViewBag.ChartDetails[10]).Add();
                          pt.X("20").Y(ViewBag.ChartDetails[15]).Add();
                          pt.X("25").Y(ViewBag.ChartDetails[20]).Add();
                          pt.X("30").Y(ViewBag.ChartDetails[25]).Add();

                      }).Name("Fuel").Tooltip(sr1 => sr1.Visible(true).Template("Tooltip")).Add();

              })
          .CanResize(true)

          .Title(title => title.Text("Fuel Consumption  "))
          .Size(sz => sz.Height("450").Width("450"))
          .Legend(lg => { lg.Visible(true); })
                        )
                        <script>
                            $("#controlarea").css("visibility", "visible");
                        </script>
                    </div>
user3428508
  • 73
  • 2
  • 10

1 Answers1

0

Set some viewbag in controller like Viewbag.IsControlNeed = true;

Then check in View Like below

@if(Viewbag.IsControlNeed)
{
// Your Control render code
}
Andi AR
  • 2,678
  • 2
  • 23
  • 28
  • But it says ViewBag doesnt exisit in current context – user3428508 Sep 19 '15 at 19:46
  • see this links.Solve view bag issues.http://stackoverflow.com/a/28431531/2632619. http://stackoverflow.com/a/15553331/2632619 . If you don't want solve the issue try Session["IsControlNeeded"] = true instead of viewbag. – Andi AR Sep 19 '15 at 19:54