带有javascript文件的html图表
我有一个显示图表的javascript文件(jquery.visualize.plugin.js) 首先,我在一个带有中继器控件的.aspx页面中显示。所以我有这个: 就在下面,我有这张图。它在.aspx页面中运行良好 现在,我想显示在HTML页面,但它不工作 这是我的Html页面:带有javascript文件的html图表,javascript,jquery,html,asp.net,Javascript,Jquery,Html,Asp.net,我有一个显示图表的javascript文件(jquery.visualize.plugin.js) 首先,我在一个带有中继器控件的.aspx页面中显示。所以我有这个: 就在下面,我有这张图。它在.aspx页面中运行良好 现在,我想显示在HTML页面,但它不工作 这是我的Html页面: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="Scripts/jquery.visualize.plugin.js"></script>
<title></title>
<script type="text/javascript">
$(function () {
$('table').visualize({ type: 'line' }).appendTo('body');
});
</script>
</head>
<body>
<headertemplate>
<table id="table_campaigns" class="display">
<caption style="font-size:20px">Statistiek 2 : per productgroep</caption>
<thead>
<tr>
<td></td>
<th>2010</th>
<th>2011</th>
<th>2012</th>
<th>2013</th>
<th>2014</th>
</tr>
</thead>
</headertemplate>
<itemtemplate>
<tbody>
</tbody>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</body>
</html>
$(函数(){
$('table')。可视化({type:'line'})。追加到('body');
});
统计数据2:每种产品
2010
2011
2012
2013
2014
下面是我的.aspx页面,它运行良好:
<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" CodeBehind="Page_Statistiek_2.aspx.cs" Inherits="PageWebSage100.Page_Statistiek_2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script language="javascript" type="text/javascript" src="JavaScript/jquery-1.10.2.min.js"></script>
<script language="javascript" type="text/javascript" src="JavaScript/jquery.visualize.plugin.js"></script>
<link type="text/css" rel="stylesheet" href="Css/base.css"/>
<link type="text/css" rel="stylesheet" href="Css/jquery.visualize.plugin.css"/>
<script type="text/javascript">
$(function () {
$('table').visualize({ type: 'line' }).appendTo('body');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" OnItemCreated="Repeater1_ItemCreated">
<HeaderTemplate>
<table>
<caption style="font-size:20px">Statistiek 2 : per productgroep</caption>
<thead>
<tr>
<td></td>
<th scope="col"><asp:Label runat="server" ID="Ym4"></asp:Label></th>
<th scope="col"><asp:Label runat="server" ID="Ym3"></asp:Label></th>
<th scope="col"><asp:Label runat="server" ID="Ym2"></asp:Label></th>
<th scope="col"><asp:Label runat="server" ID="Ym1"></asp:Label></th>
<th scope="col"><asp:Label runat="server" ID="Ym0"></asp:Label></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<th style="text-align:left" scope="row"><%# DataBinder.Eval(Container.DataItem, "Interventie") %></th>
<td><%# Math.Round(((PageWebSage100.WebServiceSage100.Statistic_2)Container.DataItem).Sum[0],2) %></td>
<td><%# Math.Round(((PageWebSage100.WebServiceSage100.Statistic_2)Container.DataItem).Sum[1],2)%></td>
<td><%# Math.Round(((PageWebSage100.WebServiceSage100.Statistic_2)Container.DataItem).Sum[2],2)%></td>
<td><%# Math.Round(((PageWebSage100.WebServiceSage100.Statistic_2)Container.DataItem).Sum[3],2)%></td>
<td><%# Math.Round(((PageWebSage100.WebServiceSage100.Statistic_2)Container.DataItem).Sum[4],2)%></td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
$(函数(){
$('table')。可视化({type:'line'})。追加到('body');
});
统计数据2:每种产品
我刚刚在head标签中添加了脚本。
Ps:我在HTML页面中使用dataTable
怎么了
您试图在HTML页面中使用ASP.NET Repeater控件的一部分。这是行不通的,因为Repeater只在ASPX页面中工作(使用相应的代码来处理数据绑定和/或呈现(即,
Repeater1\u itemscreated
)
如果要在HTML页面中显示该页面的内容,您有两种选择,例如使用IFRAME并在HTML页面中的IFRAME中显示原始ASPX页面,或者使用jQuery.load()
方法将ASPX页面的内容加载到HTML页面中的container DIV中
如果您想重用Repeater已经呈现的表HTML表,可以选择复制/粘贴表元素(table、tbody、tr、th、td元素的整体)但是不包括任何HeaderTemplate、ItemTemplate、FooterTemplate标记。服务器控件中呈现的HTML是什么?我编辑我的帖子,你可以看到我的HTML页面。你想知道吗?不使用aspx页面就可以从javascript文件加载图表吗?@Jayce是的,这个jQuery插件在客户端运行,它不需要aspx.As只要你能为它提供一个HTML表格-普通的HTML页面就可以了。在你的特殊情况下,表格是通过ASPX repeater控件生成的。还有其他获取数据的方法,例如对服务器进行AJAX调用或更简单(如我在回答中所说)使用
.load()
method从单独的页面加载HTML表好的,我明天会看到,我会告诉你我添加了:$(function(){$(“#includedContent”).load(“HtmlChart.HTML”);});HtmlChart.HTML:$(function(){$('table')。可视化({type:'line})。appendTo('body');});…它显示我的HtlmChart.html,它有一个表,但图表不显示。我不明白。不要将.html页面加载到您的DIV中。加载原始的.ASPX页面。