Click here to Skip to main content
15,918,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Has anyone successfully saved an asp.net chart? I've tried everything with the .saveimage() function but can't get it to work.

I'm using [^]

If you have some working code or know how, anything would help. Bonus points if you know how to save it to pdf :)
Posted

You need to set your web.config file

C#
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=~/FolderName/Temppdf/;" />


<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
       validate="false" />


XML
<handlers>
     <remove name="WebServiceHandlerFactory-Integrated" />
     <remove name="ScriptHandlerFactory" />
     <remove name="ScriptHandlerFactoryAppServices" />
     <remove name="ScriptResource" />
     <remove name="ChartImageHandler" />
     <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
      type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd"
      preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD"
      path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD"
      path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   </handlers>
 
Share this answer
 
Comments
MJ_ 19-Sep-11 10:31am    
Trying this but it seems to cause me to crash with this message,
Invalid temp directory in chart handler configuration [~\TempImages\].
Yes i am saving image using asp.net chart control by adding ImageLocation

VB
<asp:Chart ID="chartIncomeVsExpense" runat="server" BackColor="#f6f6f6" BorderSkin-SkinStyle="None"
                                                   BackSecondaryColor="White" BackGradientStyle="None" Palette="BrightPastel" BorderColor="26, 59, 105"
                                                   Height="300px" Width="935px" BorderWidth="2" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)">
 
Share this answer
 
Comments
MJ_ 19-Sep-11 9:19am    
I use the same thing but there never appears to save the image in that folder that I created. I made a folder called ~/TempImages/ and use everything the same but the server never has any files added to it from what I know.
Hi,

I've idea on how to write images into pdf .Here 'm providing link for that .


http://www.mikesdotnetting.com/Article/115/Microsoft-Chart-Controls-to-PDF-with-iTextSharp-and-ASP.NET-MVC

And onemore link is here for pdf handling in asp.net

http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx
I hope it can help you.


All the best.
 
Share this answer
 
v2
Comments
MJ_ 19-Sep-11 9:20am    
Yeah I tried looking at that but it is in vb. I tried converting what I saw to c # but couldnt really get it to do what I wanted
Muralikrishna8811 19-Sep-11 9:24am    
you can convert vb to c# there are some websites providing this feature

and one more thing is you've to import itextsharp.dll into your website.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900