Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用microsoft图表控件中的MapAreaAttributes打开新窗口_C#_.net_Asp.net_Visual Studio_Mschart - Fatal编程技术网

C# 使用microsoft图表控件中的MapAreaAttributes打开新窗口

C# 使用microsoft图表控件中的MapAreaAttributes打开新窗口,c#,.net,asp.net,visual-studio,mschart,C#,.net,Asp.net,Visual Studio,Mschart,我正在使用MS asp.net 3.5图表控件(金字塔),点击序列/数据点,我需要在一个新窗口中打开一个URL,类似于javascript window.open 现在我已经尝试了很多,但都不起作用。我无法将javascript提供给数据点 其次,我知道如果需要打开一个新窗口,MapAreaAttributes可以提供给下面提到的系列 series.MapAreaAttributes= "target='_blank'"; 但即使这样也不行 指引我!谢谢刚才我也遇到了你同样的问题 以下是解决方

我正在使用MS asp.net 3.5图表控件(金字塔),点击序列/数据点,我需要在一个新窗口中打开一个URL,类似于javascript window.open

现在我已经尝试了很多,但都不起作用。我无法将javascript提供给数据点

其次,我知道如果需要打开一个新窗口,MapAreaAttributes可以提供给下面提到的系列

series.MapAreaAttributes= "target='_blank'";
但即使这样也不行


指引我!谢谢

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

以下是解决方案,它是有效的:

请注意,在代码中使用的是单引号(')。这似乎是图表控件或其他东西不允许的。让我举一个可能有助于您理解的示例:

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

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.
在上面代码第二行的示例中,请注意我使用了双引号而不是单引号。如果你是这样写的:

"onclick=\'OpenWindow();\'"; 
这是行不通的!你必须使用双引号

另外,由于我是一名C#开发人员,您必须使用\“代码编写双引号,否则,您将得到编译器错误


我希望这有帮助!

解决方案已经解决:不使用图表控件!。感谢您的回复。非常感谢。这对从图像映射子元素执行javascript非常有帮助!