Postback events not received when embedded in a control
Posted: Thu Feb 12, 2004 4:21 pm
Hi,
I've created a web custom control containing a WebChart. This control is created dynamically in an aspx. The problems is the webcontrol doesn't receives any of the chart click events, but my control also contains a button which receives its click event properly.
Here is my control:
The code of my aspx.cs creating the control: (to save space I've only included my OnInit)
Whatever I click on the button, the event is received properly, but I receive none of the three clicks event I use. The events are received properly if I copy/paste the CreateChildControls in the aspx, but this is not a viable solution in our project.
Am I doing something wrong?
Thanks
Yves
I've created a web custom control containing a WebChart. This control is created dynamically in an aspx. The problems is the webcontrol doesn't receives any of the chart click events, but my control also contains a button which receives its click event properly.
Here is my control:
Code: Select all
[snip usings]
namespace WebApplication1
{
public class Control1: System.Web.UI.WebControls.WebControl, INamingContainer
{
protected override void CreateChildControls()
{
base.CreateChildControls ();
WebChart wChart = new WebChart();
wChart.ID = "FChart";
wChart.Chart.Aspect.View3D = false;
wChart.AutoPostback = true;
wChart.TempChart = TempChartStyle.Session;
wChart.Width = 700;
wChart.Height = 500;
wChart.ClickSeries += new Steema.TeeChart.Web.WebChart.SeriesEventHandler(wChart_ClickSeries);
wChart.ClickBackground += new Steema.TeeChart.Web.WebChart.ClickEventHandler(wChart_ClickBackground);
wChart.ClickTitle += new Steema.TeeChart.Web.WebChart.ClickEventHandler(wChart_ClickTitle);
wChart.Chart.Series.Add(new Bar(wChart.Chart));
wChart.Chart.Series[0].FillSampleValues(7);
Controls.Add(wChart);
Button wButton = new Button();
wButton.Text = "Test";
wButton.Click += new EventHandler(wButton_Click);
Controls.Add(wButton);
}
private void wChart_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, EventArgs e)
{
// never called
}
private void wChart_ClickBackground(object sender, ImageClickEventArgs e)
{
// never called
}
private void wChart_ClickTitle(object sender, ImageClickEventArgs e)
{
// never called
}
private void wButton_Click(object sender, EventArgs e)
{
((Button)sender).Text += "1"; // works
}
}
}
Code: Select all
override protected void OnInit(EventArgs e)
{
Control1 wControl = new Control1();
wControl.ID = "anIDforthecontrol";
MyPanel.Controls.Add(wControl);
InitializeComponent();
base.OnInit(e);
}
Am I doing something wrong?
Thanks
Yves