首页 新闻 赞助 找找看

openflashchart,swfobject未定义的问题

0
悬赏园豆:50 [已关闭问题]

我是新手,研究了一天还是不解。
我想用openflashchart实现柱状图,前台页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Bartype.aspx.cs" Inherits="Admin.Bartype.Bartype" %>
<%@ Register assembly="OpenFlashChart" namespace="OpenFlashChart" tagprefix="cc1" %>
<%--图表中心--%>
<!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>图标中心</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>  
        <cc1:Chart ID="Chart1" Width="950px" Height="300px" Url="Data.aspx"
            runat="server" OPath="" BorderStyle="Solid" />
    </div>
    </form>
</body>
</html>
[/code]
但是一浏览就会报错说“swfobject未定义”。根据提示调试发现页面代码变成了这样
[code=C#]


<!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><title>
 图标中心
</title></head>
<body>
    <form name="form1" method="post" action="Bartype.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwNjQ1MTY5MzJkZCmE77ZtD/5nDhazsHZDXHjlwHI6" />
</div>

    <div>  
        <span id="Chart1" OPath="" style="display:inline-block;border-style:Solid;"><script type="text/javascript" src="//aspnet_client/OpenFlashChart/js/swfobject.js"></script>
<div id="Chart1" />
<script type="text/javascript">
var so = new SWFObject("//aspnet_client/OpenFlashChart/open-flash-chart.swf", "ofc", "950px", "300px", "9", "#FFFFFF");
so.addVariable("width", "950px");
so.addVariable("height", "300px");
so.addVariable("data", "Data.aspx");
so.addParam("allowScriptAccess", "sameDomain");
so.write("Chart1");
<
[/code]
看到多了一部分,我实在不知道是哪儿多出来的,然后看到代码下面引用了一个js文件,但是路径不对,[code=JScript]script type="text/javascript" src="//aspnet_client/OpenFlashChart/js/swfobject.js">[/code]这句,因为路径的话前面不应该有“//”,然后我根据这个var =so找到了它的来源Chart.cs:
[code=C#]protected override void RenderContents(HtmlTextWriter output)
        {
            if (this.SequenceId == 0)
            {
               output.WriteLine(string.Format("<script type=\"text/javascript\" src=\"swfobject.js\"></script>", HttpRuntime.AppDomainAppVirtualPath));
            }
            if (this.SWFObject)
            {
                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("var so = new SWFObject(\"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>");
            }
            output.Write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"");
            output.WriteLine(string.Format("width=\"{0}\" height=\"{1}\" id=\"chart_{2}\" align=\"middle\">", this.Width, this.Height, this.SequenceId));
            output.WriteLine("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
            output.WriteLine(string.Format("<param name=\"movie\" value=\"{0}/aspnet_client/OpenFlashChart/open-flash-chart.swf?width={1}&height={2}&data={3}\" />", HttpRuntime.AppDomainAppVirtualPath, this.Width, this.Height, this.Url));
         
            output.WriteLine("<param name=\"quality\" value=\"high\" />");
            output.WriteLine("<param name=\"bgcolor\" value=\"#FFFFFF\" />");
            output.Write(string.Format("<embed src=\"{0}/aspnet_client/OpenFlashChart/open-flash-chart.swf?data={1}\" quality=\"high\" bgcolor=\"#FFFFFF\" width=\"{2}\" height=\"{3}\" name=\"open-flash-chart\" align=\"middle\" allowScriptAccess=\"sameDomain\" ", HttpRuntime.AppDomainAppVirtualPath, this.Url, this.Width, this.Height));

            output.WriteLine(string.Format("type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" id=\"embed_{0}\" />", this.SequenceId));
            output.WriteLine("</object>");
            if (this.SWFObject)
                output.WriteLine("</noscript>");
            this.SequenceId++;
        }
        #endregion[/code]
把[code=C#]output.WriteLine(string.Format("<script type=\"text/javascript\" src=\"{0}/aspnet_client/OpenFlashChart/js/swfobject.js\"></script>", HttpRuntime.AppDomainAppVirtualPath));

[/code]这句改成了[code=C#]output.WriteLine(string.Format("<script type=\"text/javascript\" src=\"aspnet_client/OpenFlashChart/js/swfobject.js\"></script>", HttpRuntime.AppDomainAppVirtualPath));
[/code],
把[code=C#]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));[/code]也改成了[code=C#]output.WriteLine(string.Format("var so = new SWFObject(\"aspnet_client/OpenFlashChart/open-flash-chart.swf\", \"ofc\", \"{1}\", \"{2}\", \"9\", \"#FFFFFF\");", HttpRuntime.AppDomainAppVirtualPath, this.Width, this.Height));[/code]但是调试的时候,页面下方还是报错并且动态代码显示的仍然是[code=C#]<div>  
        <span id="Chart1" OPath="" style="display:inline-block;border-style:Solid;"><script type="text/javascript" src="//aspnet_client/OpenFlashChart/js/swfobject.js"></script>
<div id="Chart1" />
<script type="text/javascript">
var so = new SWFObject("//aspnet_client/OpenFlashChart/open-flash-chart.swf", "ofc", "950px", "300px", "9", "#FFFFFF");
so.addVariable("width", "950px");
so.addVariable("height", "300px");
so.addVariable("data", "Data.aspx");
so.addParam("allowScriptAccess", "sameDomain");
so.write("Chart1");
<[/code]

请教高手这是怎么回事呢

Phenix.的主页 Phenix. | 初学一级 | 园豆:80
提问于:2009-12-22 17:40
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册