May 16, 2011, 8:56 PM
[CLOSED] Adding Activate Event to tabs throwing error
Hi,
I have created tabs at runtime and adding activate event to those created tabs, but while running it is throwing the error 'Tab' not found. Can you please check following code where I need to modify to work.
I have created tabs at runtime and adding activate event to those created tabs, but while running it is throwing the error 'Tab' not found. Can you please check following code where I need to modify to work.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public void CheckLoadingFile()
{
SortedList sLoansToOpen;
if (Session["AppListToOpen"] != null)
{
sLoansToOpen = (SortedList)Session["AppListToOpen"];
if (sLoansToOpen.Count > 0)
{
LoadAppTabs();
}
else
{
pnlFooter.Hide();
}
}
else
{
pnlFooter.Hide();
}
vpCommonPage.DoLayout();
}
public void LoadAppTabs()
{
Ext.Net.Panel pnlApp;
SortedList sAppList;
tbApplications.RemoveAll();
if (Session["AppListToOpen"] != null)
{
sAppList = (SortedList)Session["AppListToOpen"];
int j = sAppList.Count;
for (int i = 0; i < sAppList.Count; i++)
{
pnlApp = new Ext.Net.Panel();
pnlApp.ID = "App" + sAppList.GetKey(i).ToString();
if (sAppList[sAppList.GetKey(i)].ToString().Trim().Length > 0)
pnlApp.Title = sAppList[sAppList.GetKey(i)].ToString();
else
pnlApp.Title = sAppList.GetKey(i).ToString();
pnlApp.Closable = true;
//pnlApp.Listeners.Close.Handler = "CloseAppPanel('" + sAppList.GetKey(i).ToString() + "')";
pnlApp.DirectEvents.Activate.Event += pnlLoanTabs_Activate;
pnlApp.AddTo(tbApplications);
}
tbApplications.ActiveTabIndex = sAppList.IndexOfKey(j);
}
}
public void pnlLoanTabs_Activate(object sender, DirectEventArgs e)
{
}
public void btnAdd_Click(object sender, DirectEventArgs e)
{
SortedList sAppList;
int keyVal;
sAppList = (SortedList)Session["AppListToOpen"];
if (sAppList == null)
sAppList = new SortedList();
keyVal = sAppList.Count;
if (sAppList.Count > 0)
{
while (sAppList.ContainsKey(keyVal + 1))
{
keyVal += 1;
}
sAppList.Add(keyVal + 1, "Panel " + (keyVal + 1));
}
else
sAppList.Add(1, "Panel 1");
Session["AppListToOpen"] = sAppList;
CheckLoadingFile();
}
public void btnRemove_Click(object sender, DirectEventArgs e)
{
SortedList sAppList;
sAppList = (SortedList)Session["AppListToOpen"];
if (sAppList == null)
sAppList = new SortedList();
if (sAppList.Count > 0)
sAppList.Remove(sAppList.Count);
Session["AppListToOpen"] = sAppList;
CheckLoadingFile();
}
//[DirectMethod]
//public void CloseApplication(string appid)
//{
// SortedList sAppList;
// if (Session["AppListToOpen"] != null)
// {
// sAppList = (SortedList)Session["AppListToOpen"];
// if (sAppList.ContainsKey(appid))
// {
// sAppList.Remove(appid);
// Session["AppListToOpen"] = sAppList;
// }
// }
// CheckLoadingFile();
//}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var CloseAppPanel = function (appid) {
//alert(appid);
Ext.net.DirectMethods.CloseApplication(appid);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport runat="server" Layout="border" ID="vpCommonPage">
<Items>
<ext:Panel ID="pnlMain" runat="server" Padding="5" Region="Center" BodyStyle="background-color:#DCEAFB">
<Items>
<ext:Button ID="btnAddPanel" Text="Add Panel" runat="server">
<DirectEvents>
<Click OnEvent="btnAdd_Click">
</Click>
</DirectEvents>
</ext:Button><ext:Button ID="btnRemovePanel" Text="Remove Panel" runat="server">
<DirectEvents>
<Click OnEvent="btnRemove_Click">
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
<ext:Panel ID="pnlFooter" runat="server" Region="South" Height="25" Margins="0,0,0,0"
Border="false">
<Items>
<ext:TabPanel ID="tbApplications" runat="server" Height="25" AnchorHorizontal="100%"
Border="false">
<Items>
</Items>
</ext:TabPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>
Last edited by geoffrey.mcgill; May 18, 2011 at 6:45 PM.
Reason: [CLOSED]