I have visual web part and two usercontrols.
On Page_Load()
of visual web part i dynamically create userControl1
:
protected void Page_Load(object sender, EventArgs e)
{
UserControl1 userControl = Page.LoadControl(userControl1Path) as UserControl1;
userControl.ID = "UserControl1";
this.Controls.Clear();
this.Controls.Add(userControl);
}
In UserControl1 i have a button, that load second user control (UserControl2) (and it works!):
protected void GoToUserControl2_Click(object sender, EventArgs e)
{
UserContol2 userControl = Page.LoadControl(userControl2Path) as UserContol2;
userControl.ID = "UserContol2";
this.Controls.Clear();
this.Controls.Add(userControl);
}
UserControl2
also have a button, but when i click on it - click event not firing. Instead of it, button click perform redirect to UserControl1
.
Even if button does't have any event - it redirects to UserControl1
.
Help me, please!