We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Calling javascript from a Tabcountainer OnActiveTabChanged event

qz2rg4 asked
Medium Priority
Last Modified: 2013-11-08
Good day

How do I call a client side javascript from a Tabcontainer's OnActiveTabChanged event
<script language="JavaScript" type="text/JavaScript">
function ActiveTabChanged() {
            //get the tabContainer for later reference
            var tc = document.getElementById("TabContainer1a");
            //get the index of the tab you just clicked.
            var tabIndex = parseInt($find("TabContainer1a").get_activeTabIndex(), 10);
            //set the tabcontainer height to the tab panel height.
            if (tabIndex == 0) {
                tc.childNodes[1].style.height = 200;
  <cc1:TabContainer ID="TabContainer1a" runat="server"  OnActiveTabChanged = "ActiveTabChanged" ActiveTabIndex="0" CssClass="CustomTabStyle2"
            Width="657px" Height="100%">

Open in new window

Watch Question


You could try:

Protected Sub ActiveTabChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TabContainer1a.OnActiveTabChanged
    ClientScript.RegisterStartupScript(Me.GetType(), "RunActiveTabChanged", "ActiveTabChanged();", True)
End Sub


Sorry, forgot, you might want to add some checking whether the srcipt has already been registered or not:

Protected Sub ActiveTabChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TabContainer1a.OnActiveTabChanged
    If Not ClientScript.IsStartupScriptRegistered("RunActiveTabChanged") Then
        ClientScript.RegisterStartupScript(Me.GetType(), "RunActiveTabChanged", "ActiveTabChanged();", True)
    End If
End Sub


On the TabContainer you can use:

Or on individual TabPanels you can use:



Thanks for your reply.

I don't want to do a postback. As you can see in the code I want to change the tabpannel height on ActiveTabChanged

Unlock this solution and get a sample of our free trial.
(No credit card required)


When I try to call the javascript I get the following

Error 163      does not contain a definition for 'ActiveTabChanged' and no extension method 'ActiveTabChanged' accepting a first argument could be found (are you missing a using directive or an assembly reference?)

Am I missing the obvious?


Sorry when I try and compile I get the above mentioned error

I have tried to break this in every conceivable way possible, and on none of them do I get an error 163.

Yes it is almost certain your problem is something simple at this point, but what I dunno!

Could be something as simple as a misspelling, but I tried all those variations and didn't get the same error as you.

It sounds like a server error to me. Like it's trying to look for the server event ActiveTabChanged which has gotten itself associated with your TabContainer. Again I tried that and got different error, but that's not always a good indicator anyway.

Make sure:
a) on the tabcontainer (not tabpanel) you changed your property from OnActiveTabchanged to OnClientActiveTabChanged.
b) make sure you spelled everything correctly (it is case sensitive)
c) make sure you dont have a server side event property set on your control for now
d) make sure you dont have a server side event called ActiveTabChanged right now

The sample I put up works rock solid. It is using the newest ajaxcontroltoolkit TabContainer from June12. I doubt there's a bug in yours though.

e) Copy off your tabcontainer and make a new one, just adding the OnClientActiveTabChanged event and see how that goes.

You almost certainly just have something that got messed up during your testing, and its hiding.

If you want to post your code complete I will be happy to take a look.


For some reason OnClientActiveTabChanged does not show in intellesense only OnActiveTabChanged. Something stupid indeed.

So did that fix it?

I never said "something stupid" I hope...I hope I said and meant "something simple" :)

... everyone uses a control in a new way at some time or another, and everyone can use a fresh pair of eyes sometimes.

Ouch...why for you give me a "B"? I fixed it first try, on the button, easy peezy, gave you a sample, followed up quickly and thoroughly, years of experience at your disposal, all I get is points...and a "B" :(

...Yes I argued with my teachers too.


Sorry man new to EE If I could change it i would

all is forgiven lol
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.