2011-09-22 8 views
3

asp.net 차트 컨트롤에서 JS window.open 명령을 실행하고 있지만 해고되지 않습니다.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 

당신이 상태가 http://www.google.com/?status=TestStatus

주를 열어야 테스트 상태 등 링크임을 알 수있는 다음 labelURL 속성은 URL 만 걸릴 것이다.

+0

에 대한 MapAreaAttributes을 사용할 수 있나요 window.open 구문 코드 (1) 정확한 작성? –

+0

코멘트가 없습니다 ???? 제발 도와주세요. –

+0

도와주세요! –

답변

0

테스트하지 않았지만 MapAreaAttributes를 사용할 수 있습니다. 비슷한 것;

Chart1.Series[0].Points[i].LabelUrl = "http://www.google.co.in?status=" + dt.Columns[i].ColumnName.ToString(); 
series.MapAreaAttributes = "target=\"_blank\""; 

또는 다음을 수행 할 수 있습니다 (쿼리 문자열 제외).

 foreach (Series series in Chart1.Series) 
     { 
      series.MapAreaAttributes = "onclick=\"javascript:window.open('http://www.google.com');\""; 
     }  

Here은 쿼리 문자열 매개 변수 전달에 도움이 될 수있는 키워드에 대한 추가 정보를 원하시면입니다. 귀하의 경우에는

, 당신은 또한 DataPointCollection

Chart1.Series[0].Points[i].MapAreaAttributes = "onclick=\"javascript:window.open('http://www.google.co.in?status=" + dtSample.Columns[4].ColumnName.ToString() + "');\""; 
+0

window.open javascript를 사용하여 창을 열어야하므로 첫 번째 코드는 적합하지 않습니다 (작동하더라도). 따라서 나는 두 번째 코드 스 니펫 –

+0

으로 테스트 중이며 두 번째 코드 스 니펫이 작동하지 않습니다. 구현할 수있는 다른 솔루션은 무엇입니까? –

+0

이 테스트를 거쳤습니다. series.MapAreaAttributes = "onclick = \"javascript : window.open ('http://www.google.com'); \ ""; 또한 쿼리 문자열을 전달하려는 경우 여기를 살펴보십시오. http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.maparea.mapareaattributes.aspx – zero7