I am testing UltraChart inside a SharePoint webpart. I have the chart working, now I want to react to a data-click (I am not using the drilldown feature).
The code snippit below shows the chart creation and event delegate set inside CreateChildControls as recommended. The problem is that when the chart is clicked, CreateChildControls is called again and the delegate is assigned again and so the event method is never called.
Is there a better place in the life cycle to attach the event delegate? Or have I got it all completely wrong? Any suggestions will be greatly appreciated.
Cheers,
Jim.
protected override void CreateChildControls() { _chart = new UltraChart(); _chart.ID = "mychart"; _chart.ChartDataClicked += new Infragistics.UltraChart.Shared.Events.ChartDataClickedEventHandler(_chart_ChartDataClicked); ****** databind etc Controls.Add(_chart); }
void _chart_ChartDataClicked(object sender, Infragistics.UltraChart.Shared.Events.ChartDataEventArgs e) { throw new Exception("The method or operation is not implemented."); }
sorry for the delayed response-- i don't have a sharepoint testing environment set up right now, and with 8.1 going out the door in the past week, it's been busy around here.
make sure you call EnsureChildControls from the OnInit method of your web part. also, this developer's guide might interest you: http://ko.infragistics.com/uploadedFiles/Community/Downloads/7073/Building%20WebParts%20with%20NetAdvantage%20for%20ASP.NET.pdf
I started over with a new webpart and the server click event works. I cannot determine why it did not work originally but it now works :)