using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    private void Page_Load(object sender, System.EventArgs e)
    {
        LoadMyUserControl("~/WebUserControl.ascx", Panel1);
    }

    private string CurrentControl
    {
        get
        {
            return this.ViewState["CurrentControl"] == null ? string.Empty : (string)this.ViewState["CurrentControl"];
        }
        set
        {
            this.ViewState["CurrentControl"] = value;
        }
    }

    private void LoadMyUserControl(string controlName, Control parent)
    {
        parent.Controls.Clear();
        UserControl MyControl = (UserControl)LoadControl(controlName);
        string userControlID = controlName.Split('.')[0];
        MyControl.ID = userControlID.Replace("/", "").Replace("~", "");
        parent.Controls.Add(MyControl);
        this.CurrentControl = controlName;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //this.LoadMyUserControl("~/WebUserControl.ascx", Panel1);
    }
}
