I am trying to get a chart in my view and I will show it as follows:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>ChartResult</h2> <% using (Html.BeginForm("HandleChartType", "Chart")) %> <% { %> <%= Html.DropDownList("ListItems", "Select Chart Type")%> <input type="submit" value="Set Chart" /> <%} %> <% myChart.Controls.Add(ViewData["Chart"] as Chart); %> <asp:Panel ID="myChart" runat="server"></asp:Panel> <h2>FormResults</h2> </asp:Content>
This line is <% myChart.Controls.Add (ViewData ["Chart"] in the form of a diagram); %> generates an error message. OutputStream not available if custom TextWriter is used
This is the controller code:
public ActionResult ChartResult() { List<string> items = GetFilteredChartTypes(); ViewData["ListItems"] = new SelectList(items); Chart myChart = CreateChart(SeriesChartType.Column); ViewData["Chart"] = myChart; return View(); }
The CreateChart function simply creates a chart with a chart type in the form of a column. Why am I getting this error, OutputStream is not available if a custom TextWriter is used?
user228720
source share