using System; |
using System.Collections; |
using System.Configuration; |
using System.Data; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.HtmlControls; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
|
public partial class NestedTabDynamicUC_NestedTabDynamicUC : System.Web.UI.Page |
{ |
#region Properties |
|
private string LatestLoadedControlName |
{ |
get { return (string)ViewState["LatestLoadedControlName"]; } |
set { ViewState["LatestLoadedControlName"] = value; } |
} |
|
#endregion |
|
#region Page Events |
|
protected void Page_Load(object sender, EventArgs e) |
{ |
if (LatestLoadedControlName != null) |
{ |
LoadUserControl(LatestLoadedControlName); |
} |
else |
{ |
LoadUserControl("WebUserControl.ascx"); |
} |
} |
|
#endregion |
|
#region Tabs Events |
|
protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e) |
{ |
lblMessage.Text = e.Tab.Text + " " + e.Tab.SelectedIndex.ToString() + " " + e.Tab.ID; |
|
switch (e.Tab.ID.ToUpper()) |
{ |
case "I0": |
LoadUserControl("WebUserControl.ascx"); |
break; |
case "I1": |
LoadUserControl("WebUserControl2.ascx"); |
break; |
default: |
LoadUserControl("WebUserControl.ascx"); |
break; |
} |
|
} |
|
private void LoadUserControl(string controlName) |
{ |
if (LatestLoadedControlName != null) |
{ |
Control previousControl = pnlControls.FindControl(LatestLoadedControlName.Split('.')[0]); |
if (!Object.Equals(previousControl, null)) |
{ |
this.pnlControls.Controls.Remove(previousControl); |
} |
} |
string userControlID = controlName.Split('.')[0]; |
Control targetControl = pnlControls.FindControl(userControlID); |
if (Object.Equals(targetControl, null)) |
{ |
UserControl userControl = (UserControl)this.LoadControl(controlName); |
//slashes and tildes are forbidden |
userControl.ID = userControlID.Replace("/", "").Replace("~", ""); |
this.pnlControls.Controls.Add(userControl); |
LatestLoadedControlName = controlName; |
} |
} |
|
#endregion |
} |
|