我正在绘制图表aspx page
。该图表被放置在一个<div>
. 我需要更新唯一的具体<div>
内容,以便我可以chart
每 1 秒更新一次,而无需刷新整个页面。
下面是我的代码
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="chart">
<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" Height="455px" Width="473px" BackColor="DarkGray" BackGradientStyle="Center" BackHatchStyle="BackwardDiagonal" BackImageTransparentColor="0, 192, 192">
<Series>
<asp:Series Name="Series1" ChartType="FastPoint" XValueMember="dt" YValueMembers="Id" XValueType="DateTime"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT top(100) [dt], [Id] FROM [Test4] order by Id desc"></asp:SqlDataSource>
</div>
</asp:Content>