May 17, 2012, 4:53 AM
Look at the updated Example, I updated my sample "completeness" according to your suggestion you gave below...
Basically once the user switches to another Tab, I want to remove the previous User Control and Load it back again to the ACTIVE TAB...
I could have one (1) tab or ten (10) tabs which ALL would be loaded with the SAME User Control, so I don't wanna load ALL TABS, but ONLY 1 when ever it becomes Active.
Look at my example below... The issue is the TEXTBOX in the example below DOES NOT load within the TAB, it loads up OUTSIDE which in INCORRECT...
I could have one (1) tab or ten (10) tabs which ALL would be loaded with the SAME User Control, so I don't wanna load ALL TABS, but ONLY 1 when ever it becomes Active.
Look at my example below... The issue is the TEXTBOX in the example below DOES NOT load within the TAB, it loads up OUTSIDE which in INCORRECT...
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Panel=Ext.Net.Panel" %>
<%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Session["previousTab"] = null;
var lines = new List<string>() { "Line 1", "Line 2", "Line 3", "Line 4" };
int[] index = { 1 };
foreach (var line in lines)
{
//* NEW Tab Panel */
var tab = new Panel
{
ID = "TabBreadLine_" + index[0],
AutoHeight = true,
Title = line,
Padding = 6
};
// ONLY loads the FIRST TAB...
if (index[0] == 1)
{
//var userControl = LoadControl("~/UserControls/Runs.ascx");
//userControl.ID = "LineUserControl_" + index[0];
//* NEW Label */
var label = new Ext.Net.Label
{
ID = "Label_" + index[0],
Text = line,
FieldLabel = line
};
tab.ContentControls.Add(label);
}
tab.Listeners.Activate.Handler = "Ext.net.DirectMethods.LoadActiveTab('" + line + "'," + index[0] + ");";
TabBakeryLines.Items.Add(tab);
index[0]++;
}
}
}
[DirectMethod]
public void LoadActiveTab(string line, string index)
{
if (Session["previousTab"] != null)
{
X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
var previousTab = X.GetCmp<Panel>("TabBreadLine_" + Session["previousTab"]);
previousTab.ClearContent();
// *************************************************************
var activeTab = X.GetCmp<Panel>("TabBreadLine_" + index);
//var uc = LoadControl("~/UserControls/test.ascx");
//uc.ID = "LineUserControl_" + index;
//* NEW Label */
var label = new Ext.Net.Label
{
ID = "Label_" + index[0],
Text = line,
FieldLabel = line
};
activeTab.ContentControls.Add(label);
activeTab.UpdateContent();
}
Session["previousTab"] = index;
}
</script>
<html>
<head>
<title>Example of Issue </title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TabPanel ID="TabBakeryLines" runat="server" AutoHeight="true" StyleSpec="padding-left:2px;" />
</form>
</body>
</html>
Last edited by RonaldR; May 17, 2012 at 6:07 AM.
Reason: Updated Sample...