1

Below is the "truncated" code for an Ajax TabContainer I'm using for my web page. I need to find the tab index for the container in a JavaScript function, however I continue to get the error message "Microsoft JScript runtime error: Object expected" when this line of code is called in the JavaScript:

        function doValidate() {
            var tabIndex = $('#tabs_header span.ajax_tab_active').index()

If I comment out the "var tabIndex..." part I do not get the error, so I'm wondering if someone can tell me what is going on here. Below is the code for the tabContainer. I've "truncated" because it is a very large form with over 12 text box inputs. Both tabs represent two different methods of doing a search. By clicking on the "Search" button, the doValidate() method is the first action called, before the site even goes into the code behind. Also, I receive the same error message on the same line of code no matter which tab is active.

    <asp:TabContainer ID="AdvOrBasicSearch" runat="server" ActiveTabIndex="0">
    <div id="tabs_header">
        <span id="tab1" class="ajax_tab_active">
        <asp:TabPanel ID="basicSearch" runat="server" HeaderText="Basic Search">.../asp:TabPanel>                

        </span>
        <span id="tab2" class="ajax_tab_active">
        <asp:TabPanel ID="advSearch" runat="server" HeaderText="Advanced Search">...</asp:TabPanel>
        </span>
    </div>
    </asp:TabContainer>
1
  • 1
    No need to show us your .NET code, the rendered HTML/JavaScript is all that matters here. Commented Sep 12, 2012 at 16:59

1 Answer 1

1

I found the answer to this question very quickly. I needed to create a JS variable that was the the tabContainer itself. Then, I just needed to go inside and grab the _activeTabIndex property value. Below is the altered code

        function doValidate() {
            var tabIndex = $find("AdvOrBasicSearch");
            var i = tabIndex._activeTabIndex; 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.