maksuda Report post Posted October 31, 2008 Hi: I have developed a fusion chart in ASP(C#). It's coding and XML pages are ok as it's working properly, but when I try to call the function on a On Button_Click event , it does not display, it displays only when I call the function from my .aspx page. I tried both ways..... protected void Button1_Click(object sender, EventArgs e){GetYearlySummaryChartHtml();}[/Code]it's not working.........please need help................. Share this post Link to post Share on other sites
Arindam Report post Posted November 1, 2008 Hi, Could you please send us full source code? Share this post Link to post Share on other sites
maks Report post Posted November 3, 2008 Thanks for the reply. Here is my full code: .aspx page <% @ Page Language="C#" AutoEventWireup="true" CodeFile="Quarterly_Report.aspx.cs" Inherits="Quarterly_Report" %><% @ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %><! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">< html xmlns="http://www.w3.org/1999/xhtml" >< head runat="server"> <title>FusionCharts - Quarterly Chart</title> <script language="javascript" src="FusionCharts/FusionCharts.js" type="text/javascript"></script> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /> <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css" rel="stylesheet" type="text/css" /></ head>< body> <form id="form1" runat="server"> <div> <% -- <%=GetQuarterlySummaryChartHtml()%> --%> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" /><br /> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" DisplayToolbar="False" /> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQLServerConnection %>" SelectCommand="SELECT * FROM [View_EventCount_FiscalQtr]"></asp:SqlDataSource> <br /> <br /> <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="TagTypeDesc" HeaderText="TagTypeDesc" SortExpression="TagTypeDesc" /> <asp:BoundField DataField="Q1-2008" HeaderText="Q1-2008" SortExpression="Q1-2008" /> <asp:BoundField DataField="Q2-2008" HeaderText="Q2-2008" SortExpression="Q2-2008" /> <asp:BoundField DataField="Q3-2008" HeaderText="Q3-2008" SortExpression="Q3-2008" /> <asp:BoundField DataField="Q4-2008" HeaderText="Q4-2008" SortExpression="Q4-2008" /> </Columns> </asp:GridView> <br /> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False" DataSourceID="SqlDataSource1" Height="50px" Width="174px"> <Fields> <asp:BoundField DataField="TagTypeDesc" HeaderText="TagTypeDesc" SortExpression="TagTypeDesc" /> <asp:BoundField DataField="Q1-2008" HeaderText="Q1-2008" SortExpression="Q1-2008" /> <asp:BoundField DataField="Q2-2008" HeaderText="Q2-2008" SortExpression="Q2-2008" /> <asp:BoundField DataField="Q3-2008" HeaderText="Q3-2008" SortExpression="Q3-2008" /> <asp:BoundField DataField="Q4-2008" HeaderText="Q4-2008" SortExpression="Q4-2008" /> </Fields> </asp:DetailsView> </div> </form></ body></ html> .aspx.cs Page: using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Text;using InfoSoftGlobal;using DataConnection;using System.Windows.Forms;using CrystalDecisions.CrystalReports.Engine;using CrystalDecisions.Shared;public partial class Quarterly_Report : System.Web.UI.Page{ public string GetQuarterlySummaryChartHtml(){ StringBuilder xmlData = new StringBuilder(); SqlConnection mySQLconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ConnectionString); SqlCommand mySqlSelect = new SqlCommand("SELECT TagTypeDesc as Type from TagType where TagTypeDesc<>'Delete' ", mySQLconnection); mySqlSelect.CommandType = CommandType.Text; SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlSelect); DataSet myDataSet = new DataSet(); mySqlAdapter.Fill(myDataSet, "Type"); ArrayList myArrayList = new ArrayList(); foreach (DataRow dRow in myDataSet.Tables[0].Rows){ myArrayList.Add(dRow);} xmlData.Append("<chart labelDisplay='Rotate' slantLabels='1' caption='Quarterly Report' subCaption=' ' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix='' "); xmlData.Append(" seriesNameInToolTip='1' XAXISNAME='Quarter' lineThickness='5' reverseLegend='0' anchorAlpha='100' anchorRadius='5' setAdaptiveYMin='5' drawAnchors='1'>"); xmlData.Append("<categories>"); xmlData.Append("<category label='Q1-2008' /><category label='Q2-2008' /><category label='Q3-2008' /><category label='Q4-2008' />"); xmlData.Append("</categories>"); foreach (Object objRow in myArrayList){ xmlData.AppendFormat("<dataset seriesName='{0}' showValues='0'>", (((DataRow)objRow)["Type"].ToString())); string quarterlyQuery = "select * from (select " + "case when month(EarliestEvent) in (11,12,1) then 'Q1' else " + "case when month(EarliestEvent) in (2,3,4) then 'Q2' else " + "case when month(EarliestEvent) in (5,6,7) then 'Q3' else " + "case when month(EarliestEvent) in (8,9,10) then 'Q4' end end end end +'-'+ " + "cast(case when month(EarliestEvent) in (11,12) then year(EarliestEvent)+1 else year(EarliestEvent) end as varchar(4)) as fiscyr," + "TagType.TagTypeDesc, isnull(Sum(EventCount),0) as ttl from TagType INNER JOIN " + "TagDetails ON TagType.TagTypeID = TagDetails.TagTypeID INNER JOIN " + "IdsDataTest ON TagDetails.[TagName (Unique)] = IdsDataTest.TagName INNER JOIN " + "SensorCategories ON IdsDataTest.AgentIP = SensorCategories.SensorIP " + "WHERE (TagType.TagTypeDesc = '" + (((DataRow)objRow)["Type"].ToString()) + "' ) group by " + "case when month(EarliestEvent) in (11,12,1) then 'Q1' else " + "case when month(EarliestEvent) in (2,3,4) then 'Q2' else " + "case when month(EarliestEvent) in (5,6,7) then 'Q3' else " + " case when month(EarliestEvent) in (8,9,10) then 'Q4' end end end end +'-'+ " + " cast( case when month(EarliestEvent) in (11,12) then year(EarliestEvent)+1 else year(EarliestEvent) end as varchar(4)), " + " TagType.TagTypeDesc)t " + " pivot ( " + " sum(ttl) " + " for fiscyr in ([Q1-2008],[Q2-2008],[Q3-2008],[Q4-2008])" + " )as p "; DataConnection.DbConn oRs = new DbConn(quarterlyQuery); if (oRs.ReadData.Read()){ xmlData.AppendFormat("<set value='{0}' />", oRs.ReadData["Q1-2008"].ToString()); xmlData.AppendFormat("<set value='{0}' />", oRs.ReadData["Q2-2008"].ToString()); xmlData.AppendFormat("<set value='{0}' />", oRs.ReadData["Q3-2008"].ToString()); xmlData.AppendFormat("<set value='{0}' />", oRs.ReadData["Q4-2008"].ToString());} xmlData.Append("</dataset>");} xmlData.Append("<styles><definition><style name='CanvasAnim' type='animation' param='_xScale' start='100' duration='1' /> </definition>"); xmlData.Append("<application><apply toObject='Canvas' styles='CanvasAnim' /> </application> </styles>"); xmlData.Append("</chart> "); return FusionCharts.RenderChart("FusionCharts/StackedColumn3D.swf", "", xmlData.ToString(), "FactorySum", "600", "600", false, false);} protected void Page_Load(object sender, EventArgs e){ ReportDocument myReportDocument; myReportDocument = new ReportDocument(); myReportDocument.Load(Server.MapPath("CRReportsGLOBAL_IDS_STATISTICS_FISCALQTR.rpt")); CrystalReportViewer1.ReportSource = myReportDocument;} protected void Button1_Click1(object sender, EventArgs e){ GetQuarterlySummaryChartHtml();} } Thanks......... Share this post Link to post Share on other sites
Arindam Report post Posted November 3, 2008 Hi, Could you please add Literal control on design page above the button after try this code? on .aspx page <%-- <%=GetQuarterlySummaryChartHtml()%> --%><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <asp:Literal ID="Literal1" runat="server"></asp:Literal> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" /> on .aspx.cs Page: Change Button1_Click1 code to protected void Button1_Click1(object sender, EventArgs e){ Literal1.Text = GetQuarterlySummaryChartHtml(); } If you want that chart will show on page load then please add this code to page_load event Literal1.Text = GetQuarterlySummaryChartHtml(); Share this post Link to post Share on other sites
maks Report post Posted November 4, 2008 thank you very much........... my page is working and FusionChart is appearing........ For my curisity ........why I need to use <asp:Literal ID="Literal1" runat="server"></asp:Literal> <br /> I mean what is the function of that part in report? Another thing I want to know...... I am passing parameter from DropDownList and my chart is produced on that parameter..... when I call the chart it appears on the same page so at the bottom of the page my paramater fields and also button are still present. Is there any way to generate the chart in a new page ? See the picture below please...... Thank you very much again. Maksuda... Share this post Link to post Share on other sites
Arindam Report post Posted November 4, 2008 Hi, Literal control used as a place holder for FusionCharts. I am just forcing FusionCharts to be rendered in that region. Could you please create another page? There you can render FusionCharts depending on request object variables. Could you please see our blue print application? Share this post Link to post Share on other sites
maks Report post Posted November 5, 2008 Tahank you Arindam. Maksuda... Share this post Link to post Share on other sites