Reputation: 33
I am using the TabContainer in my asp.net app. It has 15 tabs (TabPanels). I would like to redirect a user to a URL when the first tab is clicked. I also need to add some querystring values to the URL.
I tried this is the code behind:
protected void TabContainer_ActiveTabIndexChanged()
{
if (TabContainer1.ActiveTabIndex == 0)
{
string redirectURL = "Case.aspx?Action=0&CaseId=" + lblCaseId.Text + "&ChildId=" + lblChildId.Text
Response.Redirect(redirectURL);
}
}
And this in the ASPX page:
<cc1:TabPanel ID="TabPanel8" runat="server" OnClientClick="TabContainer_ActiveTabIndexChanged">
However, it broke the page.
Thanks for your time.
Upvotes: 0
Views: 6054
Reputation: 2631
If you add the event handler in your Tab Container tag. I think it will do the trick (presuming your event handler is coded properly).
It should look something like this:
<cc1:TabContainer ID="TabContainer1" runat="server" OnActiveTabChanged="TabContainer_ActiveTabIndexChanged">
Also, you will need to eliminate the OnClientClick
from your (all) individual tabs
Upvotes: 1
Reputation: 1985
You are doing it in a wrong way.
OnClientClick="TabContainer_ActiveTabIndexChanged"
This method is to run on JavaScript side, if you want to do in JavaScript write a function in JavaScript and write your logic there.
If you want server side use
ActiveTabChanged
And write an if condition to find which tab is active and write your logic there
Upvotes: 2