为什么谷歌图表不显示在添加RUNAT =&QUOT时,服务器"?

编程入门 行业动态 更新时间:2024-10-27 12:28:05
本文介绍了为什么谷歌图表不显示在添加RUNAT =&QUOT时,服务器"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个DIV:

<div> <asp:Literal ID="lt" runat="server"></asp:Literal> </div> <div id="chart_div1" style="width: 900px; height: 500px;"></div>

它运行良好,并能显示柱状图非常精细。该bindchart()函数我把我的codebehind:

It run well and can show the barchart very fine. The bindchart() function I put in my codebehind:

.. str.Append(@"<script type=text/javascript> google.load( *visualization*, *1*, {packages:[*corechart*]}); google.setOnLoadCallback(drawChart); function drawChart() { ... str.Append(@"<script type=text/javascript> google.load( *visualization*, *1*, {packages:[*corechart*]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); .. str.Append(" var chart = new google.visualization.ColumnChart(document.getElementById('chart_div1'));"); str.Append(" chart.draw(data,{isStacked:true, width:900, height:350, hAxis: {showTextEvery:1, slantedText:true}});}"); ... str.Append("</script>"); lt.Text = str.ToString().TrimEnd(',').Replace('*', '"'); ...

但是,当我添加

"runat="server"

为ID =chart_div1

to id = "chart_div1"

<div> <asp:Literal ID="lt" runat="server"></asp:Literal> </div> <div id="chart_div1" runat="server" style="width: 900px; height: 500px;"></div>

然后我可以看到格显示为空白,无法看到图形!为什么它是如此奇怪的这样呢?我需要把=服务器,这样我可以在我的code认识落后于进一步进程的ID。任何建议?

then I can see the div appear as blank and cannot see the graph ! Why it is so strange like that ? I need to put runat="server" so that I can recognize the id in my code behind for further process. Any suggestion ?

推荐答案

也许是asp自动命名它变成你的chart_div1变成类似ctl00_ContentPlaceHolder1_chart_div1。如果你的目标ASP.NET 4.0你可以在页面指令,刚刚成立的ClientIDMode =静态这个设定。这将产生的ID正是因为你有他们在你的控制。

Perhaps it's asp auto naming which turns your "chart_div1" into something like "ctl00_ContentPlaceHolder1_chart_div1". If you're targeting ASP.NET 4.0 you can switch this off in page directive, just set ClientIDMode="Static". This will produce ID's exactly as you have them in your controls.

更多推荐

为什么谷歌图表不显示在添加RUNAT =&QUOT时,服务器&QUOT;?

本文发布于:2023-06-08 03:57:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   服务器   RUNAT   QUOT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!