UpdatePanel 内的图像在 Firefox 中不起作用

发布于 2024-07-17 16:25:34 字数 2724 浏览 5 评论 0原文

我有一个在 Ajax UpdatePanel 内自动生成的图像。 该图像是从服务器端代码生成的图表。 谷歌一搜,发现是FF的bug。 有人有解决办法吗?

这是源代码(它还包含不需要的标签,我只是复制粘贴)

<div>
   <asp:UpdatePanel ID="UpdatePanelGraph" runat="server" UpdateMode="Conditional">
       <ContentTemplate>
           <asp:Panel ID="pnlGraph" runat="server" CssClass="container">
                <div id="chart">
                     <Web:ChartControl ID="chartExchange" runat="server" Width="300px" Height="200px" BorderStyle="None" GridLines="both" DefaultImageUrl="../images/noData.png" ShowTitlesOnBackground="False" BorderWidth="1px" Padding="1" HasChartLegend="False" BottomChartPadding="20" TopChartPadding="5" RightChartPadding="5" LeftChartPadding="20">
                            <Border Color="211, 224, 242"></Border>
                            <YAxisFont ForeColor="115, 138, 156" Font="Tahoma, 7pt" StringFormat="Far,Center,Character,LineLimit"></YAxisFont>
                            <XTitle ForeColor="115, 138, 156" StringFormat="Center,Near,Character,LineLimit">
                            </XTitle>
                            <XAxisFont ForeColor="115, 138, 156" StringFormat="Near,Near,Character,NoClip"></XAxisFont>
                            <Background Type="LinearGradient" Color="#C9DEFD" ForeColor="Transparent" EndPoint="500, 500">
                            </Background>
                            <ChartTitle ForeColor="51, 51, 51" Font="Verdana, 9pt, style=Bold" StringFormat="Near,Near,Character,LineLimit">
                            </ChartTitle>
                            <Charts>
                                <Web:SmoothLineChart Name="buy" Legend="Blen">
                                    <Line Color="ActiveCaption"></Line>
                                    <DataLabels>
                                        <Border Color="Transparent"></Border>
                                        <Background Color="Transparent"></Background>
                                    </DataLabels>
                                </Web:SmoothLineChart>
                                <Web:ColumnChart Name="avgChart">
                                </Web:ColumnChart>
                            </Charts>
                            <YTitle ForeColor="115, 138, 156" StringFormat="Center,Near,Word,LineLimit"></YTitle>
                    </Web:ChartControl>
                </div>                
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

I have an image that is generated automatically inside an Ajax UpdatePanel. This image is a graph that is generated from server-side code. Searching in Google, I realised it was a bug of FF. Does anybody have any solution?

Here is the source (it contains also unneeded tags, I just copied-paste)

<div>
   <asp:UpdatePanel ID="UpdatePanelGraph" runat="server" UpdateMode="Conditional">
       <ContentTemplate>
           <asp:Panel ID="pnlGraph" runat="server" CssClass="container">
                <div id="chart">
                     <Web:ChartControl ID="chartExchange" runat="server" Width="300px" Height="200px" BorderStyle="None" GridLines="both" DefaultImageUrl="../images/noData.png" ShowTitlesOnBackground="False" BorderWidth="1px" Padding="1" HasChartLegend="False" BottomChartPadding="20" TopChartPadding="5" RightChartPadding="5" LeftChartPadding="20">
                            <Border Color="211, 224, 242"></Border>
                            <YAxisFont ForeColor="115, 138, 156" Font="Tahoma, 7pt" StringFormat="Far,Center,Character,LineLimit"></YAxisFont>
                            <XTitle ForeColor="115, 138, 156" StringFormat="Center,Near,Character,LineLimit">
                            </XTitle>
                            <XAxisFont ForeColor="115, 138, 156" StringFormat="Near,Near,Character,NoClip"></XAxisFont>
                            <Background Type="LinearGradient" Color="#C9DEFD" ForeColor="Transparent" EndPoint="500, 500">
                            </Background>
                            <ChartTitle ForeColor="51, 51, 51" Font="Verdana, 9pt, style=Bold" StringFormat="Near,Near,Character,LineLimit">
                            </ChartTitle>
                            <Charts>
                                <Web:SmoothLineChart Name="buy" Legend="Blen">
                                    <Line Color="ActiveCaption"></Line>
                                    <DataLabels>
                                        <Border Color="Transparent"></Border>
                                        <Background Color="Transparent"></Background>
                                    </DataLabels>
                                </Web:SmoothLineChart>
                                <Web:ColumnChart Name="avgChart">
                                </Web:ColumnChart>
                            </Charts>
                            <YTitle ForeColor="115, 138, 156" StringFormat="Center,Near,Word,LineLimit"></YTitle>
                    </Web:ChartControl>
                </div>                
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

哭泣的笑容 2024-07-24 16:25:34

您使用什么版本的 .NET? 3.5 框架有一个新的图形控件。 我花了几天时间试用它,并对它的强大功能感到惊讶。 我也在 UpdatePanels 中使用它,没有任何问题。

What version of .NET are you using? The 3.5 framework has a new graphing control. I spent a few days playing around with it, and was surprised at how powerful it is. And I also used it in UpdatePanels without any problems whatsoever.

看海 2024-07-24 16:25:34

这也不是一个好的解决方案,将可缓存性设置为 nocache 解决了我的问题。 我在我的页面加载上写下了这个

  Response.Cache.SetCacheability(HttpCacheability.NoCache);

它也可以通过设置此代码来工作

<script type="text/javascript">

      var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_pageLoaded(pageLoaded);
      var c = 0;
      function pageLoaded(sender, args)
      {
      var img = document.getElementById("ctl00_ctl00_MainContent_MainContent_chartExchange");
      c++;
      img.src = img.src + "?" + c;
      }

</script>

Also it is not a good solution, setting the cacheability to nocache resolved my problem. I worte this on my pageload

  Response.Cache.SetCacheability(HttpCacheability.NoCache);

It also works by setting this code

<script type="text/javascript">

      var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_pageLoaded(pageLoaded);
      var c = 0;
      function pageLoaded(sender, args)
      {
      var img = document.getElementById("ctl00_ctl00_MainContent_MainContent_chartExchange");
      c++;
      img.src = img.src + "?" + c;
      }

</script>
誰認得朕 2024-07-24 16:25:34

在我看来,无论如何,您在 FF 或 IE 上都应该遇到同样的问题。

我在你的更新面板上注意到你有,

UpdateMode="Conditional"

但你没有指定任何触发器。 这意味着更新面板的内容不会被除更新面板内我看不到的任何按钮之外的任何其他内容触发。 尝试将 UpdateMode 更改为“始终”进行调试,看看是否可以解决您的问题,并从那里找出适当的触发器。

It looks to me that you should have the same problem on FF or IE, regardless.

I've noticed on your updatepanel that you have

UpdateMode="Conditional"

but you don't specify any triggers. what that means is the content of the update panel will not get triggered by anything else other than any buttons inside the update panel which I don't see. Try changing the UpdateMode to Always for debugging and see if that fixes your problem, and work out the appropriate trigger from there.

花开雨落又逢春i 2024-07-24 16:25:34

编辑:

您可以控制如何创建图形名称/文件名并将其呈现到浏览器吗? 浏览器可以缓存图像吗? 我在使用 AJAX 调用在 Java/JSP 中进行图形打包时遇到了问题。 我必须将 GUID 附加到 AJAX url 查询字符串变量来解决缓存问题。

EDIT:

Can you control how the graphic name/file name gets created and rendered to the browser? Could the image be cached by the browser? I had issues with a graphing packing in Java/JSP with AJAX calls. I had to append a GUID to my AJAX url query string variable to fix the caching issue.

弃爱 2024-07-24 16:25:34

使用 FireBug 进行的一些挖掘让我发现,无论我选择 120 Ditë 还是 30 Ditë 或梅萨塔雷特。 看起来您的图表控件返回了相同的图像 URL,即使其背后的数据发生了变化。 对我来说听起来像是控件中的错误。

您可以使用 WebCharts 目录中的 web.config 来设置从那里提供的图像的可缓存性,以使它们永远不会被缓存。

Some digging with FireBug led me to discover that exactly the same image URL is being returned whether I select 120 Ditë or 30 Ditë or mesataret. Looks like your charting control is returning the same image URL, even when the data behind it changes. Sounds to me like a bug in the control.

You may be able to use a web.config in the WebCharts directory to set the cacheability of images served from there, to cause them never to be cached.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文