Jump to content
Software FX Community

Can't get Chart.Click event working


User (Legacy)

Recommended Posts

I can't get the Chart.Click event to work in my ASP.NET chart FX page. 

The event handler is not getting executed. Any ideas?

Here is a standalone aspx demonstrating the problem. What do I need to

do differently?

Thanks

CM

<%@ Page Language="C#" AutoEventWireup="True" Debug="True" %>

<%@ Import Namespace="SoftwareFX.ChartFX.Internet.Server"%>

<%@ Import Namespace="System.Drawing"%>

Welcome to my first .aspx page that contains a chart:

<script runat="server">

protected SoftwareFX.ChartFX.Internet.Server.Chart Chart1;

protected override void OnInit(EventArgs args) {

base.OnInit(args);

Chart1 = new SoftwareFX.ChartFX.Internet.Server.Chart(this);

Chart1.Click += new MouseEventHandlerX(OnClick);

}

protected override void OnPreRender(EventArgs args) {

Chart1.OpenData(SoftwareFX.ChartFX.COD.Values, 1, 8);

Chart1.Value[0, 0] = 0.0;

Chart1.Value[0, 1] = 0.1;

Chart1.Value[0, 2] = 0.2;

Chart1.Value[0, 3] = 0.3;

Chart1.Value[0, 4] = 0.4;

Chart1.Value[0, 5] = 0.5;

Chart1.Value[0, 6] = 0.6;

Chart1.Value[0, 7] = 0.7;

Chart1.CloseData(SoftwareFX.ChartFX.COD.Values);

}

void OnClick(object sender, MouseEventArgsX args) {

int seriesIndex = args.Series;

int pointIndex = args.Point;

if (seriesIndex > -1 && pointIndex > -1) {

Chart1.Point[seriesIndex, pointIndex].Color = Color.Red;

}

}

</script>

<form runat="server">

<%= Chart1.GetHtmlTag("500","350",".NET")%>

</form>

Link to comment
Share on other sites

In order for the event to be fired back to the server you must have the

chart inside a WebForm (this applies to any WebForms component).

Without the Page infrastructure it is just not possible to send events back

to the server. In your case the chart is not a child control of the page,

hence the chart can not ask the page for its postback address and the page

can not find the chart when the PostBack is received to hand the control to

the appropriate event.

Bottom-line: you need to make your page a WebForm, with the chart being part

of the control tree. The easiest way to do this is to use Visual Studio, I

guess you can find documentation on how to this manually in MSDN.

--

FP

Software FX

Link to comment
Share on other sites

  • 8 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...