.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Printing MS Chart Control C# ASP.NET

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
I found a pretty good post on how to create a Print Helper class to print controls but am having quite a bit of difficulty getting it to work with MS Chart controls. Just to make sure the code worked in general, I used it with a drop down list control and it worked just fine. I tried placing the chart control within a panel and used the panel as the control to print, to no avail. Here is the code for the PrintHelper class I found: public class PrintHelper { public PrintHelper() { } public static void PrintWebControl(Control ctrl) { PrintWebControl(ctrl, string.Empty); } public static void PrintWebControl(Control ctrl, string Script) { StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); if (ctrl is WebControl) { Unit w = new Unit(691, UnitType.Pixel); ((WebControl)ctrl).Width = w; } Page pg = new Page(); pg.EnableEventValidation = false; if (Script != string.Empty) //if (Script == string.Empty) { pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script); } HtmlForm frm = new HtmlForm(); pg.Controls.Add(frm); frm.Attributes.Add("runat", "server"); frm.Controls.Add(ctrl);

View Complete Post

More Related Resource Links

using jquery tooltip with asp:Chart control


I'm trying to use qtip (jquery plugin) instead of the standard tooltip control provided for the asp:Chart. I think the best way to do this is with an img map, though I don't know how to implement it. Does anyone know how to implement the img map for an asp:Chart?

WPF Chart Control

Hi,I'm trying to locate the WPF chart control that Microsoft treated as an intern project a while back: http://channel9.msdn.com/ShowPost.aspx?PostID=232493  The reason that I'm interested is that I'm in the process of taking a Windows Forms graph control (think of a line graph versus a bar chart) and converting it to be a WPF one . and would be very interested in taking a look at what those two interns had done . to try and determine best practices and the right approach for our new WPF graph control. I contacted Kevin Moore and he thought that this component was getting pretty close to being released to the public. Anyone know the current status of it? Thanks, Cory

Printing Landscape Report using the Print Control of the ASP.NET Report Viewer

I am using the ASP.NET Report Viewer 2010 web control in remote processing mode connected to a SQL Server Reporting Services 2008 R2 report server in Native Mode. I am viewing the report in IE8 and the print control within the report viewer is available. According to "Printing Reports from a Browser Using the Print Control" at http://msdn.microsoft.com/en-us/library/ms159237.aspx  "The Print dialog box and the default printer settings for width, height, and page orientation are determined by the report definition." In SQL Server Business Intelligence Development Studio I am using the “Report Properties” window accessed from the “Report” menu to set the Orientation to “Landscape”, the paper size to “Letter”, the Width to “11in”, and the Height to “8.5in” in the report definition. When viewing the report using the ASP.NET Report Viewer 2010 in IE8 and exportint to PDF, the report renders correctly in landscape orientation and the size both on screen and printed is as defined in the report definition. However, if I print it directly from the ASP.NET Report Viewer using the Print Control the print preview shows the report correctly in landscape orientation and page size, but the resulting printout is in portrait orientation and skewed or cropped.  If I go into the properti

Chart control with sqldatasource?

Hi,I am working with chart controls in VS 2010. I have used sqldatasource. I want to populate select values from sqldatasource and display it on the chart controls.According to the chart samples: http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418the chart controls are databound in the page_load event. Then in which page event should I select data from sqldatasource?Code for sqldatasource selection will also be appreciated.Regards,ap.

Pfobldm while printing from CR control in browser

Hi,      I am experiencing a problem while printing from CR viewer control from browser. Insted of printing report to printer whole web page gets printed. I am using VS2008 and FW 3.5 ASP.NET Nilkanth Desai  

Chart Control

I have a chart control in  my web page which is working fine on my local machine but the time I deploy my site on server, the chart control is causing prob........... I installed seperate exe for chart control...and copy dll as well but still error continues......can anybody help me?

Chart Control 3.5 - X-axis Labels

I have a fairly basic line graph which is bound to a SQLDataSource control.  The graph displays perfectly, but I want the labels on the X-axis to display vertically rather than horizontally.I have used the following code to try and do this but it is having no effect:<AxisX Title="Patient Safety Submissions" IsLabelAutoFit="True">    <LabelStyle Angle="90" interval="1" /></AxisX>Can anyone help?Here is the complete code for my chart:<asp:Chart ID="chrtHHcompliance" runat="server" DataSourceID="sqlHHcompliance" Width="1000px">                    <Titles>                        <asp:Title Font="Microsoft Sans Serif, 12pt, style=Bold, Underline"                                    Name="Title1" Text="Hand Hygiene Weekly Percentage Compliance">                 &nbs

How to draw Triangle in ASP.NET Chart Control

Hi I am looking for a control that can draw a very customized chart in ASP.NET.  The chart comprises: 1. A closed triangle, or polygon, shaded, drawn according to a fixed set of xy vertices. 2. A series of x,y points plotted on top of the triangle or polygon. I thought the chart Control wasthe best, but I can't figure out how to draw the close triangle or polygon. Is GDI+ the better way? Thanks   Alan

GridView data to Chart Control


I have a GridView that is filled with databound data.  My problem is that I have a template field that uses the index + 1 for the gridview to give each record a unique number.  Then with this Gridview, with BoundFields and TemplateFields, I want to have this data to be the data for the chart control series.  How exactly is the best way to go about this?

Thanks in advance. :)

MS Chart control used in sharepoint webpart


Hello all,

I am using MS Chart control on sharepoint site. But i want to attach scrollbar to x and y axis .

Is there any way to attach scrollbar?

Chart Control getting numbers from GridView, but just duplicates


I have a gridview that I loop through to get the x and y values of the chart control, and upon the first execution of this code, it looks great.  But when the page posts back and it "refreshes" data, the original points on the chart control are still there, as well as the new values.

Is there any way to "delete" all data in the chart control to ensure this doesn't happen?  I can't seem to find any resources to help me out with this.

Thanks in advance. :)

Chart Control - Dashboards


What is the status of Microsoft ehancing the Chart Control to do dashboards, easily.


Chart Control


I have never been so frustrated. I have a Chart Control working that has one datapoint seies. However when I try to run one that has two series in the collection I keep getting the run time error "Additional information: A chart element with the name 'Week' could not be found in the 'SeriesCollection'." This is a problem because I have checked everything. I have named an item named Week in the SeriesCollections.Is there another setting that I need to be aware of . Please I need help. Thanks In Advance.

Chart Control


I am having a very difficult time rendering a chart control with 2 series of data. I can render a chart with one series of data but not with 2 series. When I run my app with the 2 series chart I dont get an error or anything I just get a blank chart. Does anyone know whats going on? Thanks for any help. I'm on a very tight deadline.

Chart Control doesn't show all labels



I'm trying to create a very simple Column chart.

There are 10 items in X axis, but chart shows only 3 of their labels.

For clarification, I'm trying to show Product sales count in chart. There are 10 products. In X axis, chart shows 10 products but, only 3 of them has a label for product name.

It should be a setting for this, bu I couldn't find it.

Thanks in advance

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend