从asp.net图表控件打开一个新窗口
Opening a new window from asp.net chart control
我正在发射JS窗口。从asp.net图表控件中打开命令,但是没有启动。
下面是一个.aspx页面的代码,它将构建一个金字塔。
<div>
<asp:Chart ID="Chart1" runat="server" Height="416px" ImageType="Jpeg"
Width="525px" IsMapAreaAttributesEncoded="True" Palette="None"
PaletteCustomColors="Navy; DarkBlue; DarkBlue; DarkBlue; DarkBlue; DarkBlue; DarkBlue"
TextAntiAliasingQuality="SystemDefault" ImageStorageMode="UseImageLocation">
<Series>
<asp:Series BackGradientStyle="DiagonalRight" BackSecondaryColor="Black"
BorderColor="Black" ChartType="Pyramid" Color="Transparent"
CustomProperties="Pyramid3DRotationAngle=8, PyramidMinPointHeight=60, PyramidPointGap=3, PyramidLabelStyle=Inside"
Font="Verdana, 8pt, style=Bold" IsValueShownAsLabel="True" Name="Series1"
ShadowColor="Black" LabelForeColor="White" Palette="Grayscale">
<Points>
<asp:DataPoint CustomProperties="PyramidInsideLabelAlignment=Top"
Label=" xxxxxx Column-1"
ToolTip="1111" YValues="40"/>
<asp:DataPoint CustomProperties="PyramidInsideLabelAlignment=Top"
Label="xxxxxx Column-2" MapAreaAttributes="" ToolTip="2222"
YValues="40" />
<asp:DataPoint CustomProperties="PyramidInsideLabelAlignment=Top"
Label="xxxxxx Column-3" MapAreaAttributes="" ToolTip="" Url=""
YValues="40" />
<asp:DataPoint CustomProperties="PyramidInsideLabelAlignment=Top"
Label=" xxxxxx Col4" MapAreaAttributes="" ToolTip="" Url=""
YValues="40" />
<asp:DataPoint
Label=" xxxxxx Col5" MapAreaAttributes="" ToolTip="" Url=""
YValues="40" />
<asp:DataPoint Label=" xxxxxx Col6" MapAreaAttributes="onClick='javascript:OpenPage();'" ToolTip="" Url=""
YValues="40" />
<asp:DataPoint CustomProperties="PyramidInsideLabelAlignment=Bottom"
Label="xx Col7" MapAreaAttributes="" ToolTip="" Url="" YValues="40" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<Area3DStyle Enable3D="True" IsRightAngleAxes="False" Perspective="30"
Inclination="45" PointGapDepth="1000" Rotation="60" />
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
后面的代码是;
protected void Page_Load(object sender, EventArgs e)
{
string statusClicked = string.Empty;
Series series = new Series("MySeries");
series.ChartType = SeriesChartType.Pyramid;
series.BorderWidth = 3;
DataTable dt = new DataTable();
dt.Columns.Add("Column-1", typeof(int));
dt.Columns.Add("Column-2", typeof(int));
dt.Columns.Add("Column-3.", typeof(int));
dt.Columns.Add("Column-4", typeof(int));
dt.Columns.Add("Column-5", typeof(int));
dt.Columns.Add("Column-6", typeof(int));
dt.Columns.Add("Column-7", typeof(int));
dt.Rows.Add(1400, 2240, 7660, 3410, 15, 4, 9);
int colCount = dt.Columns.Count;
List<string> xaxis = new List<string>();
List<double> yaxis = new List<double>();
Chart1.Series[0].Points[0].MapAreaAttributes = "onclick='"javascript:window.open('http://www.google.com');'"";
}
理想情况下,点击图表中的任何系列,谷歌链接应该打开,分配的状态将是从代码中获得的状态。但是代码从来没有工作过。
它打开的URL类似于;
http://localhost:1450/javascript%3avar+win%3dwindow.open('http%3a%2f%2fwww.google.com%3fstatus%3dTestStatus')%3b
这里的你可以看到状态是Test status所以应该打开的链接是http://www.google.com/?status=TestStatus
未测试,但您可以使用MapAreaAttributes。类似的;
Chart1.Series[0].Points[i].LabelUrl = "http://www.google.co.in?status=" + dt.Columns[i].ColumnName.ToString();
series.MapAreaAttributes = "target='"_blank'"";
或者你可以这样做(不带querystring);
foreach (Series series in Chart1.Series)
{
series.MapAreaAttributes = "onclick='"javascript:window.open('http://www.google.com');'"";
}
这里有更多关于关键字的信息,可以帮助您的querystring参数传递。
在您的情况下,您还可以为DataPointCollection使用MapAreaAttributes
Chart1.Series[0].Points[i].MapAreaAttributes = "onclick='"javascript:window.open('http://www.google.co.in?status=" + dtSample.Columns[4].ColumnName.ToString() + "');'"";
相关文章:
- GWT获取新旧窗口大小
- 如何在新标签/窗口中编写文本文档
- 如何在鼠标悬停在另一个图像/链接上时显示新图像/窗口
- 从服务器 c# 打开 Outlook 新邮件窗口
- 获取用户输入以设置新的窗口参数
- 为什么我不能创建新的窗口实例
- 在c中按下一个按钮,打开两个新的窗口/选项卡(不同的外部站点)
- 在新浏览器/窗口上单击提交按钮后打开PHP操作
- 如何恢复窗口,而不是打开一个新的窗口,如果它有相同的url(仍然从上一个打开)
- 如何在不制作另一个新选项卡或新浏览器窗口的情况下在同一网页中播放MPG视频/音频文件
- 如何打开一个新的窗口/选项卡没有用户的干预,而不让它被阻止
- 打开所有链接不是我的网站的一部分,在新的窗口与jquery
- 打开一个新的窗口,而浏览器没有给出警告,这是一个弹出
- 在新的窗口jquery功能不工作
- 如何使图标出现在一个新的窗口
- 如何重定向到一个新的窗口后,点击选择关于html的选项
- 如何强制电子邮件链接打开在新的窗口
- 显示更多的信息悬停在一个新的窗口,如在facebook
- 如何使用谷歌签名与重定向,而不是一个新的窗口
- 在新的窗口打开页面,没有弹出阻止使用JavaScript目标_blank