Hi there.
I am using a tabcontrol from the ajax control toolkit.
I have three tab panels inside a tab container.
My tab container is TabCon and the tab panels inside are tab1, tab2 and tab3.
How can I do that when for example I click (or selected) on Tab1, a code-behind, let us say Tab1_Clicked event would be triggered. For tab2, when I click on it, a code-behind named tab2_clicked would be triggered.
How would I be able to map the code behind events to the ajax tab control's tab clicked event?
Advice would be highly appreciated. Thanks.
I am kind of stuck with this problem. Any advice coming from those who have implemented something similar to this one?
I was able to create some javasript function but I cannot seem to map directly a function I have in my code behind so that when that java script invokes a postback, only that said code behind is triggered.
Your advice would be highly appreciated as usual.
Thanks.
If you just want to run some client-side (javascript) code, just add an OnClientClick attribute to each TabPanel.
If you want to execute some server-side (VB or C#) code, you need to implement a small hack:
Add a button control or button controls (depending on what you need to do) to the page. Set their style="display:none;".
Hi Plz check this thread
http://forums.asp.net/t/1196925.aspx
Thank u
Baba
Please remember to click "Mark as Answer" on this post if it helped you.
Hi BatutaBunsing,
As far as I know , neither TabContainer nor TabPanel has OnClick event(Server side event). In your situation, you should use ActiveTabChanged event.For example,
protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
{
switch (TabContainer1.ActiveTabIndex) {
case 0: //do someting here;
break;
case 1: //do something else;
break;
default: break;
}
}
Best regards,
Jonathan
Hi Jonatahn,
Could you provide more insight on what you have stated here?
I am a bit stuck on this tab index changed for the past few days.. search came out empty or as i must say, inadequate for my need.
thanks.
Hi BatuaBunsing,
Here is a working example that you shall modify on it.
<%@. 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"> protected void Page_Load(object sender, EventArgs e) { // We also can add below to TabContainer1_ActiveTabChanged(object sender, EventArgs e)
switch (TabContainer1.ActiveTabIndex) { case 0: OnTab0Selected(); break; case 1: OnTab1Selected(); break; default: break; } } private void OnTab0Selected() { } .......</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="true" ActiveTabIndex="1"> <ajaxToolkit:TabPanel runat="server" ID="TabPanel1"> <HeaderTemplate> TabPanel1</HeaderTemplate> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Button" /> </ContentTemplate> </ajaxToolkit:TabPanel> <ajaxToolkit:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate> TabPanel2</HeaderTemplate> <ContentTemplate> <asp:Button ID="Button2" runat="server" Text="Button" /></ContentTemplate> </ajaxToolkit:TabPanel> </ajaxToolkit:TabContainer> </form></body></html>
I hope this help.
Best regards,
Jonathan
No comments:
Post a Comment