I’m wondering if someone can help me with this. I have three TabPanels depending on which tab is clicked I would like to call a different c# function to display different content. I know I could just run all the functions when the page loads but this seems messy. I’m sure there is a way to do this but I’m not having much look. It’s possible I’m thinking about this from totally the wrong angle so please let me know if you can think of a better way to do this.
Any help would be greatly appreciated!
Example ASP.net
<ajaxToolkit:TabContainer ID="tabParameters" AutoPostBack="true" Width="100%" runat="server" ActiveTabIndex="0">
<ajaxToolkit:TabPanel ID="tabDetails" OnClientClick="Load_Details()" HeaderText="Details" runat="server">
I would nest the “functions” into WebUserControls and put them into separate TabPanels. They do nothing on Page.Load and are Invisible. Define a function “BindData” that do all the DataBinding/Time consuming – stuff. When the user changes the ActiveTab (or for the default-active-tab) make that UserControl visible and call its BindData function.
You need UpdatePanels(Updatemode=Conditional) around the UserControl and an Async-Postback-Trigger with Eventname=ActiveTabChanged so that only this Panel is reloaded.
For example on ASPX(MD_Location is the UserControl, for lack of space i only posted one but you must imagine a lot of them):
and in the Codebehind (sorry, only VB.Net available, i hope you get the idea):
Example