title: asp.net Chart Controls on a user control in MVC
body: <p>I am new to the MVC Framework. Im working on a dashboard project in the MVC framework. The project consists of a bunch of charting control in a user controls contained in a master page. I did a test on a charting control on a aspx page..and it works...but when I moved the code to a ascx (usercontrol)  the chart doesnt render. Any ideas?!?!?!...I'm stuck. Thanks in advance</p>
  
  <p>Jeff</p>
  
  <p>Code that is in in the .aspx</p>
  
  <pre><code> &lt;%
    System.Web.UI.DataVisualization.Charting.Chart Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();
    Chart1.Width = 450;
    Chart1.Height = 296;
    Chart1.RenderType = RenderType.ImageTag;
    Chart1.ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)";
  
    Chart1.Palette = ChartColorPalette.BrightPastel;
                      Title t = new Title("Program Pipeline", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
                      Chart1.Titles.Add(t);
                      Chart1.ChartAreas.Add("Prog 1");
  
    // create a couple of series
                      Chart1.Series.Add("Backlog");
                      Chart1.Series.Add("Constructed");
                      Chart1.Series.Add("Billed");
                      Chart1.Series.Add("BudgetUsed");
                      Chart1.Series.Add("Total");
  
  
  
                      Chart1.Series["Backlog"].ChartType = SeriesChartType.StackedBar100;
                      Chart1.Series["Constructed"].ChartType = SeriesChartType.StackedBar100;
                      Chart1.Series["Billed"].ChartType = SeriesChartType.StackedBar100;
                      Chart1.Series["Total"].ChartType = SeriesChartType.StackedBar100;
                      Chart1.Series["BudgetUsed"].ChartType = SeriesChartType.StackedBar100;
  
                      Chart1.Series["Backlog"]["DrawingStyle"] = "Cylinder";
                      Chart1.Series["Constructed"]["DrawingStyle"] = "Cylinder";
                      Chart1.Series["Billed"]["DrawingStyle"] = "Cylinder";
                      Chart1.Series["BudgetUsed"]["DrawingStyle"] = "Cylinder";
                      Chart1.Series["Total"]["DrawingStyle"] = "Cylinder";
  
  
                      // Bar Size
                      Chart1.Series["Backlog"]["PointWidth"] = "0.6";
                      Chart1.Series["Constructed"]["PointWidth"] = "0.6";
                      Chart1.Series["Billed"]["PointWidth"] = "0.6";
                      Chart1.Series["BudgetUsed"]["PointWidth"] = "0.6";
                      Chart1.Series["Total"]["PointWidth"] = "0.6";
  
  
  
  
                      int _total = 0;
                      int _newTotalAmt = 100 - _total;
                      foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm1"))
                      {
                          _total += obj.TotalAmount;
  
                          Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
                      }
                      Chart1.Series["BudgetUsed"].Points.AddY(0);
                      Chart1.Series["Total"].Points.AddY(_newTotalAmt);
  
  
  
                      _total = 0;
                      _newTotalAmt = 100 - _total;
                      foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmtForPLM2("plm2"))
                      {
                          _total += obj.TotalAmount;
  
                          Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
                      }
                      Chart1.Series["BudgetUsed"].Points.AddY(0);
                      Chart1.Series["Total"].Points.AddY(_newTotalAmt);
  
  
  
  
                      _total = 0;
                      _newTotalAmt = 100 - _total;
                      foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm3"))
                      {
                          _total += obj.TotalAmount;
  
                          Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
                      }
                      Chart1.Series["BudgetUsed"].Points.AddY(0);
                      Chart1.Series["Total"].Points.AddY(_newTotalAmt);
  
  
  
                    // MvcApplication1.Models.TotalPOAmount oTotal = Model.GetOverAllBudget();
  
  
  
                      // add points to series 3
                      Chart1.Series["Billed"].Points.AddY(0);
                      Chart1.Series["Constructed"].Points.AddY(0);
                      Chart1.Series["Backlog"].Points.AddY(0);
                      Chart1.Series["BudgetUsed"].Points.AddY(39);
                      Chart1.Series["Total"].Points.AddY(100);
  
  
  
    Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
    Chart1.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
                      Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
    Chart1.BorderWidth = 2;
  
                      Chart1.Legends.Add("Legend");
  
        // show legend based on check box value
                    //  Chart1.Legends["Legend1"].Enabled = ShowLegend.Checked;
  
    // Render chart control
    Chart1.Page = this;
    HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
    Chart1.RenderControl(writer);
  
  
                      //IList&lt;SelectListItem&gt; list = new List&lt;SelectListItem&gt;();
                      //SelectListItem sli = new SelectListItem();
                      //sli.Text = "test1";
                      //sli.Value = "1";
  
                      //list.Add(sli);
                      //ViewData["Test"] = list;
  
  
                   %&gt;
  </code></pre>