Loading Fusion Charts Upon Clicking Button in ASP.Net

qbap

New Member
I am trying to show my fusion chart in a specific area specially where i am calling the CreateChart function in my aspx file upon clicking a button. The way I have it right now is that the chart loads as soon as the page loads but what I would like to see is the chart only loads when the button is clicked. I have tried different ways but not able to get it right since I am not so familiar with fusion charts. ThanksHere is my ASPX file:\[code\]<table class="style1"><td class="style8"> <asp:Button ID="btnClick" runat="server" Height="29px" Text="Button" Width="158px" onclick="btnClick_Click" /> </td> <td class="style4" colspan="2"> <% =CreateChart() %> </td> </tr> </table>\[/code\]and here is my code behind:\[code\]public string CreateChart() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString); string sqlStatement = "select Status1, Count(Status1) as TotalCount from MyTable where Closing_Date = '" + txtStartClosingDate.Text + "' and Closing_Date <= '" + txtEndClosingDate.Text + "' and Status1 is not null group by Status1"; SqlCommand cmd = new SqlCommand(sqlStatement, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); string strXML; strXML = "<graph labelDisplay='auto' useEllipsesWhenOverflow='1' decimals='2' decimalPrecision='0' showValues='1' enablesmartlabels='0' showlabels='0' legendAllowDrag='1' numberSuffix=' Days' showLegend='1' pieSliceDepth='45' formatNumberScale='0'>"; while (reader.Read()) { strXML += "<set name='" + reader["Category"].ToString() + "' value='" + reader["AvgNumbers"].ToString() + "' />"; } strXML += "</graph>"; return FusionCharts.RenderChart("../FusionCharts/Pie2D.swf", "ChartID", strXML, "FactorySum", "450", "450", false, false); }\[/code\]
 
Back
Top