using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.CurrentControl != string.Empty)
        {
            LoadMyUserControl(CurrentControl, RadTabStrip1.SelectedTab.PageView);
        }

    } 
   
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
    {
        LoadMyUserControl("WebUserControl" + e.Tab.Value + ".ascx", e.Tab.PageView);
    }

    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;
    }
}