Postback events not received when embedded in a control

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
FORAC
Newbie
Newbie
Posts: 7
Joined: Thu Nov 13, 2003 5:00 am
Location: Quebec
Contact:

Postback events not received when embedded in a control

Post by FORAC » 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:

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

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Thu Feb 19, 2004 10:08 am

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

FORAC
Newbie
Newbie
Posts: 7
Joined: Thu Nov 13, 2003 5:00 am
Location: Quebec
Contact:

Post by FORAC » Thu Feb 19, 2004 3:41 pm

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

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Thu Feb 19, 2004 10:24 pm

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

FORAC
Newbie
Newbie
Posts: 7
Joined: Thu Nov 13, 2003 5:00 am
Location: Quebec
Contact:

Post by FORAC » Fri Feb 20, 2004 2:48 pm

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

Post Reply