Page 1 of 1

Postback events not received when embedded in a control

Posted: Thu Feb 12, 2004 4:21 pm
by 8879772
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:

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
		}
	}
}
The code of my aspx.cs creating the control: (to save space I've only included my OnInit)

Code: Select all

		override protected void OnInit(EventArgs e)
		{
            Control1 wControl = new Control1();
            wControl.ID = "anIDforthecontrol";
            MyPanel.Controls.Add(wControl);

            InitializeComponent();
			base.OnInit(e);
		}
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

Posted: Thu Feb 19, 2004 10:08 am
by Marc
Hello Yves,

I have tried to reproduce this by adding a button to the WebForm project with you code line ( ((Button)sender).Text += "1"; ). That responds ok and the click and paint events related to the Charts on the Form continue to work correctly.

In the first release of TeeChart for .NET there was an event recognition problem when TeeChart shared a form with other elements. That was fixed for the second update release. Please check that you are using the latest build (for VS.NET 2003, Build 1.1.1499.42325).

If you are using the latest build and the problem persists it may be worth comparing the setup of your project to the demo Webform project.

Regards,
Marc Meumann
Steema Support

Posted: Thu Feb 19, 2004 3:41 pm
by 8879772
The problem doesn't manifest itself when the chart component is directly on the webform. To see the problem, you have to create the chart in a webcontrol (which was Control1 in my example), and put that control on the webform. So in the example I created, Control1 contains a webchart and a button and I created an instance of Control1 in my webform. The button in Control1 receives its click event properly, but not the webchart. I have no problem when the chart is directly on a webform, only when the chart is contained in a webcontrol.

The project is a default C# ASP.NET Web Application, with no parameter modified. The version I was using was 1.1.1452.42972, but I updated to 1.1.1499.42325 and I still have the problem. I can send you a small zipped project with the problem if it can helps.

Thanks again

Yves

Posted: Thu Feb 19, 2004 10:24 pm
by Marc
Hello Yves,

Thanks, I had misunderstood the issue. We have been able to reproduce it and understand the cause. We are currently testing a fix that will most likely be included in the next maintenance update. The update isn't due for a few weeks but we can probably make a pre-release version available for tests quite soon.

Regards,
Marc Meumann
Steema Support

Posted: Fri Feb 20, 2004 2:48 pm
by 8879772
Thanks for your quick answer, I'll look forward your next release. Fortunatly, I don't need the click event yet.

Yves - another happy customer :D