Showing posts with label onclientactivetabchanged. Show all posts
Showing posts with label onclientactivetabchanged. Show all posts

Saturday, March 24, 2012

TabContainer + UpdatePanel + UpdateProgress + OnClientActiveTabChanged - No progress gif..

Hey all,

I'm using a combinaison of TabContainer + UpdatePanel + UpdateProgress + OnClientActiveTabChanged to dynamically load the content of each TabPanel on user selection.

Everything works fine except the UpdateProgress which does nothing!

I have written a ActiveTabChanged(sender, e) function do actually do a post back for the OnClientActiveTabChanged method. like this :

function ActiveTabChanged(sender, e) {__doPostBack('<%= TabContainer1.ClientID %>', sender.get_activeTab().get_headerText()); }

My problem at the moment is that it does not fire the UpdateProgress control.

I tried to add an hidden asp:button within each TabPanel and fire their event in javascript but as I realised, it only work for the Activated tab, since the Tab controls are not loaded until they are active...... which is after the OnClientActiveTabChanged....

Anyone have any idea of how this can be achieve ?

Many thanks

Rich

I was wondering if anyone knows where the poster above learned what properties/values were exposed by the "sender" parameter sent into the active tab changed event we can specify on the clientside. I did try the sender.get_activeTab().get_headerText() above and it does indeed work. I'm wondering what else is exposed via this parameter and if it is documented somewhere?

Thanks

Wednesday, March 21, 2012

TabContainer and OnClientActiveTabChanged

Hi,
I have a tabcontainer with 3 tabs.
On the first tab, I make some javascript controls and I would like to block the access to the 2 other tabs.

So, I add a function to the OnClientActiveTabChanged.

Here's my little test function

function clientActiveTabChanged(sender, args)
{
if ($get('<%=myControl2Test.ClientID %>').value=="1"){
var tabs = $find('<%=TabContainer1.ClientID %>');
tabs.set_activeTabIndex(0);
}
}

Using this method, I stay on right panel, but I get a Stack Error

Any help.

Stan

Hi Stan92,

My understanding of your issue is that you have three TabPanels inside a TabContainer and the second and third TabPanel are forbidden to access. If I have misunderstood, please let me know.

Stan92:

function clientActiveTabChanged(sender, args)
{
if ($get('<%=myControl2Test.ClientID %>').value=="1"){
var tabs = $find('<%=TabContainer1.ClientID %>');
tabs.set_activeTabIndex(0);
}
}

Using this method, I stay on right panel, but I get a Stack Error

Because there is a infinite loop in your code. When click on the Tab, the clientActiveTabChanged will be called and then tabs.set_activeTabIndex(0) will be excuted, now another OnClientActiveTabChanged will be fired. You can add "alert(1);" inside the clientActiveTabChanged(sender, args) function and have a test that will be make you clear.

So my solution is adding an additional condition to the function. Sentence tabs.set_activeTabIndex(0) will be execute only in the case of activeTabIndex is not zero. Here is the whole sample

<%@. Page Language="C#" %><!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>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" AutoPostBack="false" OnClientActiveTabChanged="changeTab" ActiveTabIndex="1"> <ajaxToolkit:TabPanel ID="TabPanel1" runat="server"> <HeaderTemplate>Tab1</HeaderTemplate> <ContentTemplate> <div id ="myDiv"><%=DateTime.Now.ToString()%></div> </ContentTemplate> </ajaxToolkit:TabPanel> <ajaxToolkit:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate>Tab2</HeaderTemplate> <ContentTemplate>Wonderful</ContentTemplate> </ajaxToolkit:TabPanel> </ajaxToolkit:TabContainer> <script type="text/javascript" language="javascript"> function changeTab(){ if($find("<%=TabContainer1.ClientID%>").get_activeTabIndex()!=0) $find("<%=TabContainer1.ClientID%>").set_activeTabIndex(0); } </script> </form></body></html>
I hope this help.
Best regards,
Jonathan

TabContainer Lag when loading controls by __doPostBack in OnClientActiveTabChanged

I am using a tabContainer on my web. My final product is a TabContainer nested inside of another TabContainer, but the latency is static between the two scenarios.
Here is a sample of my code:

 
 <script type="text/javascript"> function ActiveTabChanged2(sender, e) { __doPostBack(sender.get_id(), sender.get_activeTab().get_headerText()); } </script>

Container =new TabContainer(); Container.ID ="Container"; Container.OnClientActiveTabChanged ="ActiveTabChanged2"; Container.ActiveTabChanged +=new EventHandler(ActiveTabChangedServer); Container.CssClass ="ajax__tab_gray";public void ActiveTabChangedServer(object sender, EventArgs e) {string ID =""; TabContainer tab = (TabContainer)TabContainer1.ActiveTab.FindControl("Container"); TabContainer BottomTab = (TabContainer)tab.ActiveTab.FindControl("Container2"); ID = BottomTab.ActiveTab.ID.Substring(4); UpdatePanel Upd = (UpdatePanel)BottomTab.ActiveTab.FindControl("upTab_List"); Upd.ContentTemplateContainer.Controls.Add(new LiteralControl("test")); }

Now, everything functions properly with my scriptmanager catching the postback and rerouting it to an async, etc.

The problem is, there is 2 seconds where the server and client is doing absolutely nothing before it will write "test" in my updatepanel.

No matter what scenario I use, everything loads fine, the async postback is rerouted, but then after that there is 2 seconds of nothing before the text is written, as if I were to do a thread.sleep

any help would be much appreciated as this is a main part of my corporate intranet site and I would love to keep ajax as a part of that site, but 2 seconds on top of every loadtime is leading people to beleive the resource is broken as they click from tab to tab quickly with a blank page underneath each.

Thanks,

Brandon Schoen
Netlist
Sr. .Net Architect
www.netlistinc.com

0 replies... does this mean I am the only person to experience this issue?