Wednesday, March 28, 2012

tab control

dear All

I have a tab container with 2 tab panels (say tabpanel1 and tabpanel2). ONLY when tabpanel2 is selected I wanted an event to fire. can someone tell me how to do this?

a little code would be a great help.

prasad.

var tabs = $find('TabsBehaviorID');
tabs._addActiveTabChanged(YourHandlerHere);

You can then check the tab index in the handler and ignore if it is not tabpanel2.


it says unexpected character $ (Dollar sign)
This was clientside JS code that I posted that needs to be included in <script> tags...have you done that? Maybe if you could post some code that would help.

i dont quite understand..I just have a tab with two panels in the aspx code.

<cc1:TabContainer ID="TabContainer2" runat="server">
<cc1:TabPanel ID="TabPanel1" HeaderText="Tab1" runat="server">
<ContentTemplate>

</ContentTemplate>
</cc1:TabPanel>

<cc1:TabPanel ID="TabPanel2" HeaderText="Tab2" runat="server">
<ContentTemplate>

</ContentTemplate>
</cc1:TabPanel>

</cc1:TabContainer>

I want the following. When tab2 is selected, I want to do some calculations in the code behind...and display them in tab2.

on the other hand when tab1 is selected then I want nothing to happen.

How do I call this event? can you help me with some code behind?

prasad..


Ahhh...you want a server side solution. The tab container doesn't currently postback when a tab is changed so you have to force this to happen manually. The following code demonstrates this:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /><script type="text/javascript"> function ActiveTabChanged(sender, e) { __doPostBack('<%= TabContainer2.ClientID%>', sender.get_activeTab().get_headerText()); }</script><asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="conditional"> <ContentTemplate> <cc1:TabContainer ID="TabContainer2" runat="server" OnActiveTabChanged="TabContainer2_ActiveTabChanged" OnClientActiveTabChanged="ActiveTabChanged"> <cc1:TabPanel ID="TabPanel1" HeaderText="Tab1" runat="server"> <ContentTemplate> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel2" HeaderText="Tab2" runat="server"> <ContentTemplate> </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="TabContainer2" EventName="ActiveTabChanged" /> </Triggers></asp:UpdatePanel>

You can then hook up to the event in the code behind as follows:

protected void TabContainer2_ActiveTabChanged(object sender, EventArgs e){}

thank you for the code, is it possible that there is a postback only when tab panel2 is selected and NOT when tabpanel1 is selected?

prasad.


sender.get_activeTab().get_tabIndex() will tell you which tab is the new active tab so you can selectively fire the postback.


thank you. that helped.

BTW do you know how to change the tabs background color? using the

<cc1:TabPanel ID="TabPanel1" BackColor="#CECABB" runat="server">

doesnt change the color.

prasad-


http://community.bennettadelson.com/blogs/rbuckton/archive/2007/02/02/Skinning-model-for-Calendar-and-Tabs-in-Ajax-Control-Toolkit.aspx
thank you a ton!

Hi everybody!!!

Hi Would like, How do to the Tab Painel to load the content..only when it is called...because, on this samples of Jason, the content is being loaded with a firts postback.... is it possible ?

I Need this, because i've five gridviews in my page, and this stays bad...

Thank all!!!

p.s: my english isn't good


You can use dynamic population via a web service using the Dynamic* properties of the tab panel control. If the tab panels need to contain server controls that postback, then you will have to create the tab panel controls during a postback (not via a web service).

No comments:

Post a Comment