Hi Ignacio, Mi problem is exactly this (in Web)
I have:
- an aspx page
- an ascx control (Exercise1.ascx)
- an ascx control (Exercise2.ascx)
Inside the aspx page i have a placeholder to add a control dinamically.
This placeholder's name is Exercise.
In the aspx page i have this in the OnInit:
override protected void OnInit(EventArgs e)
{
if(Page.Session["Exercise"]!=null)
{
switch(Page.Session["Exercise"].ToString())
{
case "Exercise2.ascx":
Exercise2 Exercise2_=(Exercise2)LoadControl("Exercise2.ascx");
Exercise.Controls.Add(Exercise2_);
break;
}
}
else
{
Exercise1 Exercise1_=(Exercise1)LoadControl("Exercise1.ascx");
Exercise.Controls.Add(Exercise1_);
}
}
In the (for instance) Exercise1.ascx i have this in the onClick method
of a button:
private void ExerciseBtn_Click(object sender, EventArgs e)
{
//add into the session the next exercise to load
Page.Session.Add("Exercise","Exercise2.ascx");
}
If i click in the button inside the usercontrol twice the program works,
but i would like only to need one click.
Thanks.
Josema.