I’m converting from aspx view to razor. In the view I have the following code:
(i’m using dundas charts)
..
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.Width = 492;
chart.Height = 406;
chart.RenderType = RenderType.ImageTag;
chart.ImageLocation = System.Configuration.ConfigurationManager.AppSettings["Temp"] + "/TempImagesChartPic_#SEQ(200,30)";
...
...
// Render chart control
chart.Page = (Page)this;
var writer = new HtmlTextWriter(Page.Response.Output);
chart.RenderControl(writer);
this worked fine in aspx however it throws “Cannot implicitly convert type ‘System.Dynamic.DynamicObject’ to ‘System.Web.UI.Page'”
How do i make it work in razor view?
thanks
The Chart control that you are trying to use is a server side control which relies heavily on the ASP.NET WebForms infrastructure. The fact that you can use it in an ASP.NET MVC application (WebForms view engine) is only because of the heritage that this view engine has on classic WebForms. For charting in ASP.NET MVC applications (all view engines including Razor) I would recommend you using the System.Web.Helpers.Chart helper.