Sign in to follow this  
Impelsys

Chart error after downloading file in IE 7.0

Recommended Posts

Hi,

 

 

 

I have a page in which i have Column3D chart , grid and excel download button. when click on the one of the column in chart i am refreshing the grid using the JavaScript by partial post back

 

this is working fine, but when i click excel download button i have to create excel on server and have to download to client. after this when i click on the chart an error alert is coming and grid is not refreshed.

 

 

 

Error : Internet Explorer cannot download. Unspecified error.

 

 

 

The function returns the chart code :

 

 

 

return FusionCharts.RenderChartHTML("FusionCharts/Column3D.swf", "", xmlData, "ID", "240", "200", false);

 

 

 

Java script function to refresh data in grid code :

 

 

 

function callFunction(From)

 

{

 

__doPostBack("div_Details","PS$" + From);

 

}

 

 

 

Excel Download code :

 

 

 

Response.AppendHeader("Content-Type", "application/vnd.ms-excel");

 

 

 

Response.AppendHeader("Content-Disposition", "attachment; filename=" + ExcelFileName + ".xls");

 

 

 

Response.TransmitFile(Path + ".xls");

 

 

 

Response.End();

 

 

 

Please reply soon..

 

 

 

Thanks,

 

sai

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

 

 

 

ASPX code :

 

 

 

 

 

function callFunction(From)

 

{

 

var obStatus=document.getElementById('ddl_Status');

 

 

 

for (var i = 0; i < obStatus.options.length; i++)

 

{

 

if (obStatus.options[ i ].value==From)

 

{

 

obStatus.options[ i ].selected=true;

 

}

 

}

 

 

 

__doPostBack("up_Details","IS$" + From );

 

 

 

 

 

}

 

 

 

CS Code :

 

 

 

using System;

 

using System.Data;

 

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 InfoSoftGlobal;

 

using System.Text;

 

using System.Drawing;

 

 

 

public partial class Dashboard : System.Web.UI.Page

 

{

 

public string summaryQ;

 

GetHMHData GetData = new GetHMHData();

 

DataTable dt_IsuStatus = new DataTable();

 

DataTable dt_Projects = new DataTable();

 

DataTable dt_IssueDetails = new DataTable();

 

static string strSortExpression = "";

 

static string strSortDirection = "ASC";

 

static Int32 numberDiv;

 

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

string sEventArguments = this.Request.Params["__EVENTARGUMENT"];

 

 

 

if (!IsPostBack && sEventArguments==null)

 

{

 

BindStatus();

 

BindProjects();

 

BindDetails();

 

}

 

else

 

{

 

if (sEventArguments != null && sEventArguments.StartsWith("IS"))

 

{

 

sEventArguments = sEventArguments.Substring(3, sEventArguments.Length - 3);

 

 

 

BindDetails();

 

}

 

}

 

}

 

 

 

#region PageInIt

 

 

 

void Page_Init()

 

{

 

if (!IsPostBack)

 

{

 

try

 

{

 

//DataTable dt_SectionAccess = PageAuthentication.PageAuthentication(Page.GetType().Name.ToString());

 

 

 

//if (dt_SectionAccess == null)

 

//{

 

// Session["ErrorMsg"] = "Not Authorized To See The Requested Page";

 

// Response.Redirect("Error.aspx");

 

//}

 

 

 

}

 

 

 

catch (Exception ex)

 

{

 

//Session["ErrorMsg"] = ex.Message.ToString();

 

//Response.Redirect("Error.aspx");

 

 

 

}

 

 

 

}

 

}

 

 

 

#endregion PageInIt

 

 

 

#region Load Charts

 

 

 

#region Issue Details Graph Load

 

public string GetHMHDashboard_IssueChart()

 

{

 

 

 

string xmlData;

 

xmlData = "";

 

string sql_LWW_Biz_Summary = SummaryQuery("IS");

 

 

 

DataAccess objDA = new DataAccess();

 

DataTable dtLWW_Biz = objDA.fnReturnDataTable(sql_LWW_Biz_Summary);

 

 

 

foreach (DataRow row in dtLWW_Biz.Rows)

 

{

 

xmlData += "";

 

//xmlData += "";

 

}

 

 

 

dtLWW_Biz.Dispose();

 

objDA.Dispose();

 

xmlData += "";

 

 

 

return FusionCharts.RenderChartHTML("FusionCharts/Column3D.swf", "", xmlData, "LWW_Biz_Summary", "240", "300", false);

 

//return FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlData, "LWW_Biz_Summary", "240", "300", false,false);

 

}

 

#endregion Issue Details Graph Load

 

 

 

#endregion Load Charts

 

 

 

#region Get Summary Query

 

public string SummaryQuery(string ChtType)

 

{

 

switch (ChtType)

 

{

 

case "IS":

 

 

 

summaryQ = "IMP_HMH_Issues 1,''," + ddl_ProjName.SelectedValue; ;

 

 

 

break;

 

 

 

 

 

 

 

 

 

default:

 

 

 

break;

 

}

 

 

 

return summaryQ;

 

}

 

#endregion Get Summary Query

 

 

 

 

 

protected void BindStatus()

 

{

 

dt_IsuStatus = GetData.fillIssueStatus();

 

 

 

ddl_Status.DataSource = dt_IsuStatus;

 

ddl_Status.DataTextField = "Status";

 

ddl_Status.DataValueField = "Status";

 

ddl_Status.DataBind();

 

 

 

}

 

 

 

protected void BindProjects()

 

{

 

dt_Projects = GetData.fillProjects();

 

 

 

ddl_ProjName.DataSource = dt_Projects;

 

ddl_ProjName.DataTextField = "Projectname";

 

ddl_ProjName.DataValueField = "ProjectId";

 

ddl_ProjName.DataBind();

 

ddl_ProjName.Items.Insert(0, "All");

 

ddl_ProjName.Items[0].Value = "0";

 

 

 

}

 

protected void ddl_ProjName_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

BindDetails();

 

}

 

 

 

protected void BindDetails()

 

{

 

dt_IssueDetails = GetData.fillIssueDetails(ddl_Status.SelectedItem.Text,ddl_ProjName.SelectedValue);

 

 

 

SetGridDateName();

 

 

 

gv_IssueDetails.DataSource = dt_IssueDetails;

 

gv_IssueDetails.DataBind();

 

 

 

 

 

}

 

 

 

protected void ddl_Status_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

string sEventArguments = this.Request.Params["__EVENTARGUMENT"];

 

if (sEventArguments == null)

 

{

 

BindDetails();

 

}

 

 

 

}

 

protected void img_Excel_Click(object sender, ImageClickEventArgs e)

 

{

 

 

 

string ExcelPath = @"D:PegDevSerPDXLS";

 

string FileName = GetExcelName();

 

 

 

GetData.CreateExcel(gv_IssueDetails, "Issue Details", ExcelPath + FileName, false);

 

 

 

Response.ContentType = "xls";

 

Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName + ".xls");

 

Response.TransmitFile(ExcelPath + FileName + ".xls");

 

Response.End();

 

 

 

 

 

}

 

protected void gv_IssueDetails_RowCreated(object sender, GridViewRowEventArgs e)

 

{

 

try

 

{

 

if ((e.Row != null) && e.Row.RowType == DataControlRowType.Header)

 

changeSortImage(sender, e);

 

}

 

catch (Exception ex)

 

{

 

Session["ErrorMsg"] = ex.Message.ToString();

 

Response.Redirect("Error.aspx");

 

 

 

}

 

}

 

 

 

#region Change Sort Image

 

protected void changeSortImage(object sender, GridViewRowEventArgs e)

 

{

 

 

 

if ((e.Row != null) && e.Row.RowType == DataControlRowType.Header)

 

{

 

foreach (TableCell cell in e.Row.Cells)

 

{

 

if (cell.HasControls())

 

{

 

LinkButton button = (LinkButton)cell.Controls[0];

 

if ((button != null))

 

{

 

System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();

 

 

 

image.ImageUrl = "~/images/Sort_Default.gif";

 

 

 

if (strSortExpression == button.CommandArgument)

 

{

 

if (strSortDirection == "ASC")

 

{

 

image.ImageUrl = "images/Sort_Down.gif";

 

}

 

else

 

{

 

image.ImageUrl = "images/Sort_UP.gif";

 

}

 

}

 

 

 

cell.Controls.AddAt(0, image);

 

LiteralControl space = new LiteralControl("");

 

cell.Controls.AddAt(1, space);

 

 

 

}

 

}

 

}

 

}

 

 

 

 

 

 

 

}

 

#endregion Change Sort Image

 

 

 

protected void gv_IssueDetails_Sorting(object sender, GridViewSortEventArgs e)

 

{

 

try

 

{

 

dt_IssueDetails.Clear();

 

dt_IssueDetails = GetData.fillIssueDetails(ddl_Status.SelectedItem.Text, ddl_ProjName.SelectedValue);

 

 

 

DataView dv_IssueDetails = new DataView(dt_IssueDetails);

 

 

 

dv_IssueDetails.Sort = e.SortExpression;

 

strSortExpression = e.SortExpression;

 

 

 

if ((numberDiv % 2) == 0)

 

{

 

dv_IssueDetails.Sort = e.SortExpression + " " + "ASC";

 

strSortDirection = "ASC";

 

 

 

}

 

 

 

else

 

{

 

dv_IssueDetails.Sort = e.SortExpression + " " + "DESC";

 

strSortDirection = "DESC";

 

}

 

numberDiv++;

 

 

 

SetGridDateName();

 

 

 

 

 

 

 

gv_IssueDetails.DataSource = dv_IssueDetails;

 

gv_IssueDetails.DataBind();

 

 

 

 

 

 

 

}

 

catch (Exception ex)

 

{

 

Session["ErrorMsg"] = ex.Message.ToString();

 

Response.Redirect("Error.aspx");

 

 

 

}

 

}

 

 

 

private void SetGridDateName()

 

{

 

if (ddl_Status.SelectedValue.ToLower() == "go live" || ddl_Status.SelectedValue.ToLower() == "closed")

 

{

 

gv_IssueDetails.Columns[4].HeaderText = "Live Date";

 

}

 

else

 

{

 

gv_IssueDetails.Columns[4].HeaderText = "Beta Date";

 

}

 

}

 

 

 

 

 

private string GetExcelName()

 

{

 

string Excelname = "Issues_";

 

 

 

if (ddl_ProjName.SelectedItem.Text.ToLower() != "all")

 

{

 

Excelname = Excelname + ddl_ProjName.SelectedItem.Text + "_";

 

}

 

 

 

Excelname = Excelname + ddl_Status.SelectedValue + "_" + GetRandomNumber();

 

 

 

return Excelname;

 

}

 

 

 

#region Generate Random Number

 

public string GetRandomNumber()

 

{

 

Random random = new Random();

 

return random.Next(10, 10000).ToString();

 

 

 

}

 

#endregion Generate Random Number

 

}

codefiles.zip

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

 

 

 

ASPX code :

 

 

 

 

 

function callFunction(From)

 

{

 

var obStatus=document.getElementById('ddl_Status');

 

 

 

for (var i = 0; i < obStatus.options.length; i++)

 

{

 

if (obStatus.options[ i ].value==From)

 

{

 

obStatus.options[ i ].selected=true;

 

}

 

}

 

 

 

__doPostBack("up_Details","IS$" + From );

 

 

 

 

 

}

 

 

 

CS Code :

 

 

 

using System;

 

using System.Data;

 

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 InfoSoftGlobal;

 

using System.Text;

 

using System.Drawing;

 

 

 

public partial class Dashboard : System.Web.UI.Page

 

{

 

public string summaryQ;

 

GetHMHData GetData = new GetHMHData();

 

DataTable dt_IsuStatus = new DataTable();

 

DataTable dt_Projects = new DataTable();

 

DataTable dt_IssueDetails = new DataTable();

 

static string strSortExpression = "";

 

static string strSortDirection = "ASC";

 

static Int32 numberDiv;

 

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

string sEventArguments = this.Request.Params["__EVENTARGUMENT"];

 

 

 

if (!IsPostBack && sEventArguments==null)

 

{

 

BindStatus();

 

BindProjects();

 

BindDetails();

 

}

 

else

 

{

 

if (sEventArguments != null && sEventArguments.StartsWith("IS"))

 

{

 

sEventArguments = sEventArguments.Substring(3, sEventArguments.Length - 3);

 

 

 

BindDetails();

 

}

 

}

 

}

 

 

 

#region PageInIt

 

 

 

void Page_Init()

 

{

 

if (!IsPostBack)

 

{

 

try

 

{

 

//DataTable dt_SectionAccess = PageAuthentication.PageAuthentication(Page.GetType().Name.ToString());

 

 

 

//if (dt_SectionAccess == null)

 

//{

 

// Session["ErrorMsg"] = "Not Authorized To See The Requested Page";

 

// Response.Redirect("Error.aspx");

 

//}

 

 

 

}

 

 

 

catch (Exception ex)

 

{

 

//Session["ErrorMsg"] = ex.Message.ToString();

 

//Response.Redirect("Error.aspx");

 

 

 

}

 

 

 

}

 

}

 

 

 

#endregion PageInIt

 

 

 

#region Load Charts

 

 

 

#region Issue Details Graph Load

 

public string GetHMHDashboard_IssueChart()

 

{

 

 

 

string xmlData;

 

xmlData = "";

 

string sql_LWW_Biz_Summary = SummaryQuery("IS");

 

 

 

DataAccess objDA = new DataAccess();

 

DataTable dtLWW_Biz = objDA.fnReturnDataTable(sql_LWW_Biz_Summary);

 

 

 

foreach (DataRow row in dtLWW_Biz.Rows)

 

{

 

xmlData += "";

 

//xmlData += "";

 

}

 

 

 

dtLWW_Biz.Dispose();

 

objDA.Dispose();

 

xmlData += "";

 

 

 

return FusionCharts.RenderChartHTML("FusionCharts/Column3D.swf", "", xmlData, "LWW_Biz_Summary", "240", "300", false);

 

//return FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlData, "LWW_Biz_Summary", "240", "300", false,false);

 

}

 

#endregion Issue Details Graph Load

 

 

 

#endregion Load Charts

 

 

 

#region Get Summary Query

 

public string SummaryQuery(string ChtType)

 

{

 

switch (ChtType)

 

{

 

case "IS":

 

 

 

summaryQ = "IMP_HMH_Issues 1,''," + ddl_ProjName.SelectedValue; ;

 

 

 

break;

 

 

 

 

 

 

 

 

 

default:

 

 

 

break;

 

}

 

 

 

return summaryQ;

 

}

 

#endregion Get Summary Query

 

 

 

 

 

protected void BindStatus()

 

{

 

dt_IsuStatus = GetData.fillIssueStatus();

 

 

 

ddl_Status.DataSource = dt_IsuStatus;

 

ddl_Status.DataTextField = "Status";

 

ddl_Status.DataValueField = "Status";

 

ddl_Status.DataBind();

 

 

 

}

 

 

 

protected void BindProjects()

 

{

 

dt_Projects = GetData.fillProjects();

 

 

 

ddl_ProjName.DataSource = dt_Projects;

 

ddl_ProjName.DataTextField = "Projectname";

 

ddl_ProjName.DataValueField = "ProjectId";

 

ddl_ProjName.DataBind();

 

ddl_ProjName.Items.Insert(0, "All");

 

ddl_ProjName.Items[0].Value = "0";

 

 

 

}

 

protected void ddl_ProjName_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

BindDetails();

 

}

 

 

 

protected void BindDetails()

 

{

 

dt_IssueDetails = GetData.fillIssueDetails(ddl_Status.SelectedItem.Text,ddl_ProjName.SelectedValue);

 

 

 

SetGridDateName();

 

 

 

gv_IssueDetails.DataSource = dt_IssueDetails;

 

gv_IssueDetails.DataBind();

 

 

 

 

 

}

 

 

 

protected void ddl_Status_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

string sEventArguments = this.Request.Params["__EVENTARGUMENT"];

 

if (sEventArguments == null)

 

{

 

BindDetails();

 

}

 

 

 

}

 

protected void img_Excel_Click(object sender, ImageClickEventArgs e)

 

{

 

 

 

string ExcelPath = @"D:PegDevSerPDXLS";

 

string FileName = GetExcelName();

 

 

 

GetData.CreateExcel(gv_IssueDetails, "Issue Details", ExcelPath + FileName, false);

 

 

 

Response.ContentType = "xls";

 

Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName + ".xls");

 

Response.TransmitFile(ExcelPath + FileName + ".xls");

 

Response.End();

 

 

 

 

 

}

 

protected void gv_IssueDetails_RowCreated(object sender, GridViewRowEventArgs e)

 

{

 

try

 

{

 

if ((e.Row != null) && e.Row.RowType == DataControlRowType.Header)

 

changeSortImage(sender, e);

 

}

 

catch (Exception ex)

 

{

 

Session["ErrorMsg"] = ex.Message.ToString();

 

Response.Redirect("Error.aspx");

 

 

 

}

 

}

 

 

 

#region Change Sort Image

 

protected void changeSortImage(object sender, GridViewRowEventArgs e)

 

{

 

 

 

if ((e.Row != null) && e.Row.RowType == DataControlRowType.Header)

 

{

 

foreach (TableCell cell in e.Row.Cells)

 

{

 

if (cell.HasControls())

 

{

 

LinkButton button = (LinkButton)cell.Controls[0];

 

if ((button != null))

 

{

 

System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();

 

 

 

image.ImageUrl = "~/images/Sort_Default.gif";

 

 

 

if (strSortExpression == button.CommandArgument)

 

{

 

if (strSortDirection == "ASC")

 

{

 

image.ImageUrl = "images/Sort_Down.gif";

 

}

 

else

 

{

 

image.ImageUrl = "images/Sort_UP.gif";

 

}

 

}

 

 

 

cell.Controls.AddAt(0, image);

 

LiteralControl space = new LiteralControl("");

 

cell.Controls.AddAt(1, space);

 

 

 

}

 

}

 

}

 

}

 

 

 

 

 

 

 

}

 

#endregion Change Sort Image

 

 

 

protected void gv_IssueDetails_Sorting(object sender, GridViewSortEventArgs e)

 

{

 

try

 

{

 

dt_IssueDetails.Clear();

 

dt_IssueDetails = GetData.fillIssueDetails(ddl_Status.SelectedItem.Text, ddl_ProjName.SelectedValue);

 

 

 

DataView dv_IssueDetails = new DataView(dt_IssueDetails);

 

 

 

dv_IssueDetails.Sort = e.SortExpression;

 

strSortExpression = e.SortExpression;

 

 

 

if ((numberDiv % 2) == 0)

 

{

 

dv_IssueDetails.Sort = e.SortExpression + " " + "ASC";

 

strSortDirection = "ASC";

 

 

 

}

 

 

 

else

 

{

 

dv_IssueDetails.Sort = e.SortExpression + " " + "DESC";

 

strSortDirection = "DESC";

 

}

 

numberDiv++;

 

 

 

SetGridDateName();

 

 

 

 

 

 

 

gv_IssueDetails.DataSource = dv_IssueDetails;

 

gv_IssueDetails.DataBind();

 

 

 

 

 

 

 

}

 

catch (Exception ex)

 

{

 

Session["ErrorMsg"] = ex.Message.ToString();

 

Response.Redirect("Error.aspx");

 

 

 

}

 

}

 

 

 

private void SetGridDateName()

 

{

 

if (ddl_Status.SelectedValue.ToLower() == "go live" || ddl_Status.SelectedValue.ToLower() == "closed")

 

{

 

gv_IssueDetails.Columns[4].HeaderText = "Live Date";

 

}

 

else

 

{

 

gv_IssueDetails.Columns[4].HeaderText = "Beta Date";

 

}

 

}

 

 

 

 

 

private string GetExcelName()

 

{

 

string Excelname = "Issues_";

 

 

 

if (ddl_ProjName.SelectedItem.Text.ToLower() != "all")

 

{

 

Excelname = Excelname + ddl_ProjName.SelectedItem.Text + "_";

 

}

 

 

 

Excelname = Excelname + ddl_Status.SelectedValue + "_" + GetRandomNumber();

 

 

 

return Excelname;

 

}

 

 

 

#region Generate Random Number

 

public string GetRandomNumber()

 

{

 

Random random = new Random();

 

return random.Next(10, 10000).ToString();

 

 

 

}

 

#endregion Generate Random Number

 

}

codefiles.zip

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Thanks for sharing your idea.

Happy FusionCharting. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this