Adding ASP.NET charts to your web pages and Deployment Challenges
Adding charts to your ASP.NET web pages
Adding charts to your ASP.NET web pages can be easy but here are a few snags you can run into. You need to choose an ASP.NET solutions at an asp.net famework 4.0 and above. We are not going into a long tutorial on how to create charts in an ASP.NET web page as we assume you have knowledge of how in Visual Studio you go to the tool box, DATA menu section and drag and drop a CHART onto your web page and set the data source to it.
You ay have troubles compiling your web project if you see an ~~System.Web.DataVisualiization error. In order for your web project to compile, open up References in the Visual Studio UI for your asp.net project and check the check box for the System.Web.DataVisualiization reference. Then recompile.
Fixing Deployment Errors
We found for deployment reasons it was good to have this code pasted as the 2nd top line in your aspx web page (or web form) that had the chart graph on it:
<%@ Register Assembly="System.Web.DataVisualization, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
When you deploy your ASP.NET web application assuming you are deploying to a server that has asp.net famework 4.0 or above installed, and have set up the IIS application pool properly for the right asp.net framework for your web site, you might find your web application works on your laptop but fails on the deployment server. You can fix up the local web.config file inside your web project on your deployment server as it could fail with an error like this below if it does not like the c:\TempImageFiles:
Look at your path to where your files reside on the deployment server, and change the c:\TempImageFiles path to the path to where your web files exist on the deployment server.
If you are still getting errors try adding these sections to your local web.config file one at a time testing each time for the graphs to come up.
Add this under the " </configSections> " header:
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <handlers> <remove name="ChartImageHandler"/> <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </handlers> </system.webServer>
If still having trouble, add this under the " <system.web>
<httpHandlers> <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/> </httpHandlers> <pages controlRenderingCompatibilityVersion="3.5" enableEventValidation="false" clientIDMode="AutoID"> <controls> <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> </pages>
Hope this helps! Have fun!