开发者

Open a new window using MapAreaAttributes in microsoft chart control

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

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

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????

Guide me! Thanks


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:

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...

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

I hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜