SoZo Hosting 800-640-4892: Specializing In Windows Dedicated Server, Linux Dedicated Server, ColdFusion Dedicated Server, ColdFusion Hosting, Cloud Hosting, Windows Hosting, Linux Hosting, SEO, Web Full Page Ads...

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 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 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=, 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 famework 4.0 or above installed,  and have set up the IIS application pool properly for the right 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:

<appSettings> <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" /> </appSettings>

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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </handlers> </system.webServer>


If still having trouble, add this under the " <system.web> " header:

<httpHandlers> <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, 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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> </pages>



Hope this helps!  Have fun!