I have to publish my solution as well.
As to me, I think I found the better solution.
The idea of the user control is to be able to place many elementary controls on the panel and use them as one, and the second - the values in the elementary controls should be kept, whatever user enters, while he switches the set of user controls.
Now the solution.
I just created all of my controls, but instead of using PlaceHolder, I explicitly put them on the same place of the Main Page, but with the property "Visible" set to False.
Then, as the menu item is selected, I just set the property Visible of the appropriate control to True.
Therefore, it works as should to..
To place a Control of the page use the tag Register:
In my example there are 2 controls About and RegInit in MainPage.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="MyApp.MainPage" %>
<%@ Register TagPrefix="uc" TagName="About" Src="~/controls/About.ascx" %>
<%@ Register TagPrefix="uc" TagName="RegInit" Src="~/controls/RegInit.ascx" %>
And below on their's place in code:
<uc:About id="about" runat="server" Visible="true" />
<uc:RegInit id="regInit" runat="server" Visible="false" />
And in MainPage.aspx.cs
protected void MainMenu_ItemClick(object sender, MenuEventArgs e)
{
if (e.Item.Text == "ABOUT")
{
about.Visible = true;
regInit.Visible = false;
}
if (e.Item.Text == "REGISTER")
{
regInit.Visible = true;
about.Visible = false;
}
}
It is much better, because all the user data which are entered is kept, and user could continue with them by switching the controls.
I will tick the Connor's solution, but I decided to get rid of the PlaceHolder...