Mar 14, 2013, 7:41 PM
[CLOSED] TabPanel tabs activating differently if remove tabs
Hi,
In my web application I need to add tabs to tab panel at bottom of the form and based on tab selection the required information related to selected tab will show in center panel. For demo purpose I have added one toolbar at top of the form as showing in the image. In left textfield enter number of tabs required, and click Open forms button. The number of tabs will add at bottom. Just click on each tab and see the tab related info will show in the center panel.
Now add any tab number (without zeros) in right textfield in toolbar and click "Delete this number form", it will delete the entered number tab. Once delete any tab, I want to load ("ExtSampleForm.aspx"). It is working fine if we add extreme tab number and click "Delete this...", but it is not working correctly if we enter first tab number to delete. It is loading all tabs info form one by one and finally shows one tab info form, but I want to show only "ExtSampleForm.aspx" all the time when delete any tab.
The main form code...
In my web application I need to add tabs to tab panel at bottom of the form and based on tab selection the required information related to selected tab will show in center panel. For demo purpose I have added one toolbar at top of the form as showing in the image. In left textfield enter number of tabs required, and click Open forms button. The number of tabs will add at bottom. Just click on each tab and see the tab related info will show in the center panel.
Now add any tab number (without zeros) in right textfield in toolbar and click "Delete this number form", it will delete the entered number tab. Once delete any tab, I want to load ("ExtSampleForm.aspx"). It is working fine if we add extreme tab number and click "Delete this...", but it is not working correctly if we enter first tab number to delete. It is loading all tabs info form one by one and finally shows one tab info form, but I want to show only "ExtSampleForm.aspx" all the time when delete any tab.
The main form code...
<%@ 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">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.pnlMain.LoadContent("ExtSampleForm.aspx");
}
}
public void OpenAllForms(object sender, DirectEventArgs e)
{
Session["AppListToOpen"] = null;
SortedList sAppList = new SortedList();
for (int i = 1; i <= Convert.ToInt32(txtNoOfForms.Text); i++)
{
sAppList.Add(i.ToString("000000"), i.ToString("000000"));
}
Session["AppListToOpen"] = sAppList;
Session["PresetApp"] = 0;
LoadAppTabs();
CheckLoadingFile();
LoadRequiredPage();
}
public void DeleteEnteredNumber(object sender, DirectEventArgs e)
{
SortedList sAppList = (SortedList)Session["AppListToOpen"];
int keyVal = Convert.ToInt32(txtLoanNumber.Text);
sAppList.Remove(keyVal.ToString("000000"));
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = 0;
Session["AppListToOpen"] = sAppList;
LoadSearchPage();
}
public void LoadAppTabs()
{
Ext.Net.Panel pnlApp;
SortedList sAppList;
tbApplications.RemoveAll();
if (Session["AppListToOpen"] != null)
{
sAppList = (SortedList)Session["AppListToOpen"];
for (int i = 0; i < sAppList.Count; i++)
{
if (Ext.Net.X.GetCmp("App" + sAppList.GetKey(i).ToString()) == null)
{
pnlApp = new Ext.Net.Panel();
pnlApp.ID = "App" + sAppList.GetKey(i).ToString();
if (sAppList[sAppList.GetKey(i).ToString()].ToString().Trim().Length > 0)
pnlApp.Title = sAppList[sAppList.GetKey(i).ToString()].ToString();
else
pnlApp.Title = sAppList.GetKey(i).ToString();
pnlApp.Closable = true;
pnlApp.Listeners.Close.Handler = "CloseAppPanel('" + sAppList.GetKey(i).ToString() + "');";
pnlApp.Listeners.Activate.Handler = "OpenLoanSpecifcPages('" + sAppList.GetKey(i).ToString() + "');";
pnlApp.AddTo(tbApplications);
}
}
}
}
[DirectMethod()]
public void LoadSearchPage()
{
hidUrl.Text = "ExtSampleForm.aspx";
this.pnlMain.LoadContent("ExtSampleForm.aspx");
LoadAppTabs();
CheckLoadingFile();
LoadRequiredPage();
}
[DirectMethod]
public void CloseApplication(string appid)
{
SortedList sAppList;
if (Session["AppListToOpen"] != null)
{
sAppList = (SortedList)Session["AppListToOpen"];
if (sAppList.ContainsKey(appid))
{
sAppList.Remove(appid);
Session["CloseAppId"] = appid;
if (sAppList.Count > 0)
Session["AppListToOpen"] = sAppList;
else
Session["AppListToOpen"] = null;
}
}
else
sAppList = new SortedList();
CheckLoadingFile();
if (sAppList.Count > 0)
{
if (hidUrl.Text == "ExtCenterPanel.aspx")
{
int LastAppId;
LastAppId = Convert.ToInt32(sAppList.GetKey(sAppList.Count - 1).ToString());
if (Session["APPLICATION_ID"].ToString() == appid)
{
Session["APPLICATION_ID"] = LastAppId;
Session["PresetApp"] = sAppList.GetKey(sAppList.Count - 1).ToString();
LoadRequiredPage();
}
else
{
Session["APPLICATION_ID"] = Session["PresetApp"].ToString();
}
}
}
else
{
if (hidUrl.Text == "ExtSampleForm.aspx" || hidUrl.Text == "ExtCenterPanel.aspx")
{
if (hidUrl.Text != "ExtSampleForm.aspx")
{
hidUrl.Text = "ExtSampleForm.aspx";
pnlMain.LoadContent("ExtSampleForm.aspx");
}
}
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
vpCommonPage.DoLayout();
}
}
public void LoadRequiredPage()
{
string AppId = "0";
if (Session["APPLICATION_ID"] != null)
AppId = Session["APPLICATION_ID"].ToString();
if (Convert.ToInt32(AppId) == 0)
AppId = Session["PresetApp"].ToString();
if (Convert.ToInt32(AppId) > 0)
{
if (Convert.ToInt32(AppId) > 0)
{
pnlMain.LoadContent("ExtCenterPanel.aspx");
hidUrl.Text = "ExtCenterPanel.aspx";
}
else
{
if (Session["AppListToOpen"] != null)
{
SortedList sAppList;
sAppList = (SortedList)Session["AppListToOpen"];
if (sAppList.Count <= 0)
{
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
else
{
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
}
else
{
if (Session["AppListToOpen"] != null)
{
SortedList sAppList;
sAppList = (SortedList)Session["AppListToOpen"];
if (sAppList.Count <= 0)
{
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
else
{
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
}
[DirectMethod]
public void pnlLoanTabsActivate(string AppId)
{
Session["APPLICATION_ID"] = AppId;
ShowPanelActiveInactive();
}
public void ShowPanelActiveInactive()
{
SortedList sAppList = new SortedList();
if (Session["AppListToOpen"] != null)
sAppList = (SortedList)Session["AppListToOpen"];
string AppId = Session["APPLICATION_ID"].ToString();
if (Session["PresetApp"] != null)
{
if (hidUrl.Text == "ExtCenterPanel.aspx")
{
if (Session["PresetApp"].ToString() != AppId)
{
Session["PresetApp"] = AppId;
LoadRequiredPage();
}
}
else
{
LoadRequiredPage();
}
}
else
{
Session["PresetApp"] = AppId;
LoadRequiredPage();
}
}
public void CheckLoadingFile()
{
SortedList sLoansToOpen;
if (Session["AppListToOpen"] != null)
{
sLoansToOpen = (SortedList)Session["AppListToOpen"];
if (sLoansToOpen.Count > 0)
{
pnlFooter.Show();
}
else
{
if (hidUrl.Text != "ExtSampleForm.aspx")
{
hidUrl.Text = "ExtSampleForm.aspx";
pnlMain.LoadContent("ExtSampleForm.aspx");
pnlFooter.Hide();
}
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
else
{
if (hidUrl.Text == "ExtSampleForm.aspx" || hidUrl.Text == "ExtCenterPanel.aspx")
{
if (hidUrl.Text != "ExtSampleForm.aspx")
{
hidUrl.Text = "ExtSampleForm.aspx";
pnlMain.LoadContent("ExtSampleForm.aspx");
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
else
{
pnlFooter.Hide();
Session["APPLICATION_ID"] = 0;
Session["PresetApp"] = "0";
}
}
vpCommonPage.DoLayout();
}
</script>
<script language="javascript" type="text/javascript">
var CloseAppPanel = function (appid) {
Ext.net.DirectMethods.CloseApplication(appid);
}
var OpenLoanSpecifcPages = function (appid) {
Ext.net.DirectMethods.pnlLoanTabsActivate(appid);
}
function loadAfterDelete() {
Ext.net.DirectMethods.LoadSearchPage();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport runat="server" Layout="border" ID="vpCommonPage">
<Items>
<ext:Panel ID="pnlTops" runat="server" Region="North" Height="30" Border="false"
BodyStyle="background-color:#424E5A">
<TopBar>
<ext:Toolbar ID="tbPanel" runat="server">
<Items>
<ext:TextField ID="txtNoOfForms" runat="server" Text="5">
</ext:TextField>
<ext:ToolbarSeparator />
<ext:Button ID="btnOpenTabs" runat="server" Text="Open forms">
<DirectEvents>
<Click OnEvent="OpenAllForms"></Click>
</DirectEvents>
</ext:Button>
<ext:ToolbarFill />
<ext:TextField ID="txtLoanNumber" runat="server" ></ext:TextField>
<ext:ToolbarSeparator />
<ext:Button ID="btnDelete" runat="server" Text="Delete This Number Form">
<DirectEvents>
<Click OnEvent="DeleteEnteredNumber" ></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
</Items>
</ext:Panel>
<ext:Panel ID="pnlMain" runat="server" Padding="5" Region="Center" BodyStyle="background-color:#C9D9ED"
Border="false">
<AutoLoad Mode="IFrame" NoCache="true" ShowMask="true" MaskMsg="Loading..." />
</ext:Panel>
<ext:Panel ID="pnlFooter" runat="server" Region="South" Height="25" Margins="0,0,0,0"
Border="false" Hidden="true" BodyStyle="background-color:#C9D9ED">
<Items>
<ext:TabPanel ID="tbApplications" runat="server" Height="25" AnchorHorizontal="100%"
Border="false" IDMode="Explicit" EnableTabScroll="true" Plain="true">
<Plugins>
<ext:TabScrollerMenu PageSize="5">
</ext:TabScrollerMenu>
</Plugins>
<Items>
</Items>
</ext:TabPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
<ext:Hidden ID="hidUrl" Text="" runat="server">
</ext:Hidden>
</form>
</body>
</html>
The center panel ("ExtCenterPanel.aspx") code ...<%@ 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">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
lblAppNumber.Text = Session["APPLICATION_ID"].ToString();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport runat="server" Layout="border" ID="vpCommonPage">
<Items>
<ext:Panel ID="pnlCenter" runat="server" Padding="5" Region="Center" BodyStyle="background-color:#C9D9ED"
Border="false">
<Items>
<ext:Label ID="lblAppNumber" runat="server" Text="label"></ext:Label>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
And Sample form ("ExtSampleForm.aspx") code...<%@ 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">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Sample Form
</div>
</form>
</body>
</html>
Last edited by Daniil; Mar 21, 2013 at 6:58 AM.
Reason: [CLOSED]