Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
151068 | Jan 29,2020 07:14 PM UTC | Feb 11,2020 05:42 AM UTC | ASP.NET Web Forms | 7 |
![]() |
Tags: Chart |
ChartFeatures.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<ej:Chart ID="Chart1" OnServerExporting="ExportChart">
<ExportSettings Mode="Server" />
</ej:Chart>
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
function download() {
$("#Chart1").ejChart("export");
}
</script>
</asp:Content>
ChartFeatures.aspx.cs
protected void ExportChart(object sender, Syncfusion.JavaScript.Web.ChartEventArgs e)
{
string Format = "png";
string FileName = "Chart";
string DataURL = e.Arguments["Data"].ToString();
DataURL = DataURL.Remove(0, DataURL.IndexOf(',') + 1);
MemoryStream stream = new MemoryStream(Convert.FromBase64String(DataURL));
stream.WriteTo(Response.OutputStream);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", FileName + "." + Format));
Response.Flush();
stream.Close();
stream.Dispose();
} |
ChartFeatures.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<ej:Chart ID="Chart1" runat="server" OnServerExporting="ExportChart">
</ej:Chart>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
ChartFeatures.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bindChartData();
}
}
private void bindChartData()
{
//Binding Datasource to Chart Series
for (int j = 0; j < this.Chart1.Series.Count; j++)
{
this.Chart1.Series[j].DataSource = data;
}
this.Chart1.DataBind();
} |
Hi Durga.I think I found the problem but I don't know how to solve... Every time I export the chart the application does two postback: one from the chart control and the other from the button. Here is my Page_Load function:protected void Page_Load(object sender, EventArgs e){if (!IsPostBack){Listdata = new List (); data.Add(new ColumnChartData("USA", 50, 70, 45));data.Add(new ColumnChartData("China", 40, 60, 55));data.Add(new ColumnChartData("Japan", 70, 60, 50));data.Add(new ColumnChartData("Australia", 60, 56, 40));data.Add(new ColumnChartData("France", 50, 45, 35));data.Add(new ColumnChartData("Germany", 40, 30, 22));data.Add(new ColumnChartData("Italy", 40, 35, 37));data.Add(new ColumnChartData("Sweden", 30, 25, 27));//Binding Datasource to Chartthis.Chart1.DataSource = data;this.Chart1.DataBind();}}I check if it is not a postback to prevent reloading the chart with the initial values (as it can be filtered by the RangeDatePicker control).But this render the chart empty on the page every time I export.So, should I reload the chart with the current liteblue value from the RangeDatePicker on every postback or there is a way to send the postback for export but without having to reload the chart control?Thanks for the support. Regards.
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.