Friday, August 8, 2008

Solution for Operation Aborted message in openflashchart 1.9.7 for IE

Hi...

I am using openflashchart 1.9.7 an open source chart generation tool (url) for graphical presentations in my application. It really has a nice look & feel which is more presentable. I made use of it & created awesome charts in my application. The Graph work well in Firefox but the same page in IE 7.0 was showing Operation aborted error.
I was puzzled & was pretty much sure that there was nothing wrong in the code. So its time to dig into the open source control... It was in Chart.cs the Codes written specific to IE was the reason. I checked it with my friend, a flash programmer who said there needs to be a DIV tag which has to come above the existing DIV added for I.E.

Following is the Code to be added in RenderContents Method in Chart.cs


if (this.SequenceId == 0)
{
output.WriteLine(string.Format("<script type=\"text/javascript\" src=\"{0}/aspnet_client/OpenFlashChart/js/swfobject.js\"></script>", HttpRuntime.AppDomainAppVirtualPath));
}

if (this.SWFObject)
{
output.WriteLine(string.Format("<div id=\"{0}\" >", this.ClientID));
output.WriteLine("</div>");
//output.WriteLine(string.Format("<div id=\"{0}\" />", this.ClientID));
output.WriteLine("<script type=\"text/javascript\">");
output.WriteLine(string.Format("var so = new SWFObject(\"{0}/aspnet_client/OpenFlashChart/open-flash-chart.swf\", \"ofc\", \"{1}\", \"{2}\", \"9\", \"#FFFFFF\");", HttpRuntime.AppDomainAppVirtualPath, this.Width, this.Height));
output.WriteLine(string.Format("so.addVariable(\"width\", \"{0}\");", this.Width));
output.WriteLine(string.Format("so.addVariable(\"height\", \"{0}\");", this.Height));
output.WriteLine(string.Format("so.addVariable(\"data\", \"{0}\");", this.Url));
output.WriteLine("so.addParam(\"allowScriptAccess\", \"sameDomain\");");
output.WriteLine(string.Format("so.write(\"{0}\");", this.ClientID));
output.WriteLine("</script>");
output.WriteLine("<noscript>");
}

Built the project & replaced the new dll & now the chart works fine in IE too :)

Regards
Fauzi

1 comment:

josmunpav said...

Thank you very much. I spent many hours before find your solution.

Thanks again