Skip to content

@carlhoerberg /Chart.ascx
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Web.UI.DataVisualization.Charting.Chart>" %>
<%
Model.Page = this.Page;
var writer = new HtmlTextWriter(Page.Response.Output);
Model.RenderControl(writer);
%>
public class ChartController: Controller
{
public ActionResult MyChart()
{
var chart = new Chart();
// Configure chart
return View(chart);
}
}
protected void Application_Start()
{
// It's importat that this ignore of any url ending with ChartImg.axd is inserted before any Area route registrations.
// If you won't use Charts in any Area you can put it in your RegisterRoutes() method.
RouteTable.Routes.Ignore("{*pathInfo}", new { pathInfo = @"^.*(ChartImg.axd)$" });
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
// The rest..
}
<% Html.RenderPartial("Chart", Model); %>
<?xml version="1.0"?>
<configuration>
<!-- Your stuff -->
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
</appSettings>
<!-- Your stuff -->
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<!-- Other assemblies -->
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<!-- Your stuff -->
<httpHandlers>
<!-- Other handlers -->
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
</system.web>
<!-- Your stuff -->
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.