How can ensurechildcontrols help? I have different "stages" of controls. Not
all child controls should be createt at the same time. Small sample code:
(Sorry but perhaps my biggest problem is that I couldn't describe my problem
with the right words.)
public class Test_Control : WebControl
{
Button but1 = new Button();
Button but2 = new Button();
Button but3 = new Button();
protected override void CreateChildControls()
{
this.FirstControl(this, new EventArgs());
}
private void FirstControl(object sender, System.EventArgs e)
{
this.but1.Text = "Button 1";
this.but1.EnableViewState = true;
this.but1.ID = "but1";
this.but1.Click += new EventHandler(this.SecondControl);
Controls.Add(but1);
}
private void SecondControl(object sender, System.EventArgs e)
{
this.but2.Text = "Button 2";
this.but2.EnableViewState = true;
this.but2.ID = "but2";
this.but2.Click += new EventHandler(this.ThirdControl);
Controls.Add(but2);
}
private void ThirdControl(object sender, System.EventArgs e)
{
this.but3.Text = "Button 3";
this.but3.EnableViewState = true;
this.but3.ID = "but3";
Controls.Add(but3);
}
}
At the beginning only Button1 should be created. Button1 should create
Button2. Works fine. Button2 should create Button3. But only Button1 is
createt (from createchildcontrols). So i need to know which controls where
in the list before the roundtrip.