我尝试使用Visual Studio(2015)提供的asp:Chart控件在我的页面中创建图表。但由于某些原因,我无法在代码隐藏页面上配置图表本身(例如,尝试为图表设置数据源)。
这是我在页面上的内容:
`
<%@ Page Title="GERM | Dashboard Analista" Language="C#" AutoEventWireup="true" CodeBehind="DashboardAnalista.aspx.cs" Inherits="WebApplication1.Auditores.Auditorias" MasterPageFile="~/Analistas.Master" Async="true" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h3>Dashboard de Analista.</h3>
<br />
<div class="row">
<div class="col-md-6 text-center">
<div class="panel panel-default" runat="server">
<div class="panel-heading">
<h3 class="panel-title">Gráfico de XYZ</h3>
</div>
<asp:Chart ID="Chart11" runat="server" DataSourceID="dschart11">
<titles>
<asp:title text="Descripción del título del gráfico" bordercolor="Red"></asp:title>
</titles>
<Series>
<asp:Series Name="Series1">
<points>
<asp:datapoint axislabel="Max" yvalues="20"></asp:datapoint>
<asp:datapoint axislabel="Ron" yvalues="10"></asp:datapoint>
<asp:datapoint axislabel="Jack" yvalues="5"></asp:datapoint>
<asp:datapoint axislabel="Harry" yvalues="30"></asp:datapoint>
<asp:datapoint axislabel="Smith" yvalues="40"></asp:datapoint>
</points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</div>
<div class="col-md-6 text-center">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Gráfico de XYZ</h3>
</div>
<asp:Chart ID="Chart2" runat="server">
<titles>
<asp:title text="Descripción del título del gráfico" bordercolor="Red"></asp:title>
</titles>
<Series>
<asp:Series Name="Series1">
<points>
<asp:datapoint axislabel="Max" yvalues="20"></asp:datapoint>
<asp:datapoint axislabel="Ron" yvalues="10"></asp:datapoint>
<asp:datapoint axislabel="Jack" yvalues="5"></asp:datapoint>
<asp:datapoint axislabel="Harry" yvalues="30"></asp:datapoint>
<asp:datapoint axislabel="Smith" yvalues="40"></asp:datapoint>
</points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 text-center">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Gráfico de XYZ</h3>
</div>
<asp:Chart ID="Chart3" runat="server">
<titles>
<asp:title text="Descripción del título del gráfico" bordercolor="Red"></asp:title>
</titles>
<Series>
<asp:Series Name="Series1">
<points>
<asp:datapoint axislabel="Max" yvalues="20"></asp:datapoint>
<asp:datapoint axislabel="Ron" yvalues="10"></asp:datapoint>
<asp:datapoint axislabel="Jack" yvalues="5"></asp:datapoint>
<asp:datapoint axislabel="Harry" yvalues="30"></asp:datapoint>
<asp:datapoint axislabel="Smith" yvalues="40"></asp:datapoint>
</points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</div>
<div class="col-md-6 text-center">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Gráfico de XYZ</h3>
</div>
<asp:Chart ID="Chart4" runat="server">
<titles>
<asp:title text="Descripción del título del gráfico" bordercolor="Red"></asp:title>
</titles>
<Series>
<asp:Series Name="Series1">
<points>
<asp:datapoint axislabel="Max" yvalues="20"></asp:datapoint>
<asp:datapoint axislabel="Ron" yvalues="10"></asp:datapoint>
<asp:datapoint axislabel="Jack" yvalues="5"></asp:datapoint>
<asp:datapoint axislabel="Harry" yvalues="30"></asp:datapoint>
<asp:datapoint axislabel="Smith" yvalues="40"></asp:datapoint>
</points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</div>
</div>
</asp:Content>
当我尝试修改时,假设'Chart11' intellisense不会自动完成我可以在Chart11上修改的不同属性,Chart2也会发生相同的情况 这是我在“代码隐藏”上看到的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.DataVisualization.Charting;
namespace WebApplication1.Analistas
{
public partial class DashboardAnalista : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
chart11 //IntelliSense is not autocompleting!!
}
}
}
`
我的aspx.designer显示了所有图表控件,所以这不是'runat=server'类问题中的bug。
我不知道我是否遗漏了一个引用或未配置的内容,但intellisense没有自动完成的事实对我来说很奇怪。
- 已更改ID以强制设计器页重新运行
- 删除图表并重新创建新图表,同样的情况也会发生。
- 已检查是否缺少“runta=server”
1条答案
按热度按时间jgwigjjp1#
我已经发现了问题:
第1行:
Inherits属性指向我站点中的其他页面。2一旦我将其指向正确的页面,我就可以“调用”.cs页面中的图表了: