在Microsoft图表控件中使用MapAreaAttributes打开一个新窗口 [英] Open a new window using MapAreaAttributes in microsoft chart control

查看:111
本文介绍了在Microsoft图表控件中使用MapAreaAttributes打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MS asp.net 3.5图表控件(金字塔),并且在单击系列/数据点时,我需要在新窗口中打开URL,例如javascript window.open.

i am using MS asp.net 3.5 chart control (Pyramid) and on the click of the series/datapoint i need to open a URL in a new window, something like javascript window.open.

现在我已经尝试了很多,但是那行不通.我无法将javascript提供给数据点.

Now i have tried a hell lot but that doesn't work. I am not able to give javascript to the datapoint.

第二,我知道如果需要打开一个新窗口,可以如下所述将MapAreaAttributes分配给Series

Secondly i got to know that MapAreaAttributes could be given to Series as mentioned below if a new window needs to be open

series.MapAreaAttributes= "target='_blank'";

但是,这还行不通吗????

But even this doesn't works????

引导我!谢谢

推荐答案

我刚才也遇到了同样的问题.

I had your same problem just now.

以下是解决方案,它可以正常工作:

Here is the solutions and it works:

在代码中请注意,您正在使用单引号(').似乎这是图表控件或其他不允许的.让我给你一个例子,可能会帮助您理解:

Notice in your code that you're using the single quotation ('). It seems that this is not allowed by the chart control or something. Let me give you an example that might help you understand:

让我们假设您有一个JavaScript函数,当用户单击数据(系列)中的列(点)时,该函数会打开一个窗口,其中显示了一些数据.您可以这样做:

Let's assume you have a JavaScript function that opens a window showing some data when the user clicks on a column (point) in your data (series). You can do it like this:

Chart1.Series["MySeries"].Points[0].Url = "javascript:void(0)"; //this is just to tell the browser not follow a URL, since you will control this with your javascript

Chart1.Series["MySeries"].Points[0].MapAreaAttributes = "onclick=\"OpenWindow();\""; //this is to set the onclick attribute to fire your javascript function when the user clicks your column.

在上面示例的第二行代码中,请注意,我使用了双引号而不是单引号.如果您这样写:

In the above example in the second line of code, notice that I have used double quotation instead of single ones. If you wrote it like this :

"onclick=\'OpenWindow();\'"; 

它将永远无法工作!您必须使用双引号...

it will never work! You have to use double quotations...

此外,由于我是C#开发人员,因此您必须使用\代码编写双引号,否则,将出现编译器错误.

Also, since I am a C# developer, you have to use the \" code to write double quotations otherwise, you will get compiler error.

我希望这会有所帮助!

这篇关于在Microsoft图表控件中使用MapAreaAttributes打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆