简体   繁体   English

使用 AjaxToolKit 的 TabContainer

[英]TabContainer using AjaxToolKit

Before I had a problem of findhing the control and setting the tab index.在我遇到查找控件和设置选项卡索引的问题之前。 My problem now is that depending if there is data in some of the tabs they are set to Visible = true or false.我现在的问题是,取决于某些选项卡中是否有数据,它们被设置为 Visible = true 或 false。 If there is no data they are not visible (the tab that is) but the container and any of the other tabs that do have data are shown.如果没有数据,则它们不可见(即选项卡),但会显示容器和任何其他具有数据的选项卡。

So when I do所以当我这样做的时候

$find('<%=myTabs.ClientID%>').set_activeTabIndex(1);

It gives me error because for that particular item there is no data in tab 0 so the tab I want to set now is at index 0 since the tab I want to set would move an index down.它给了我错误,因为对于该特定项目,选项卡 0 中没有数据,因此我现在要设置的选项卡位于索引 0,因为我要设置的选项卡会将索引向下移动。 How can I know in which index this tab is at, using javascript?使用 javascript,我如何知道该选项卡在哪个索引中?

Related code:相关代码:

function getFocus() { function getFocus() {

    //need to be able to find out at which index pnlTab2 is at.. so i can set it
    $find('<%=myTabs.ClientID%>').set_activeTabIndex(1);
    document.getElementById('<%=pnlTab2.ClientID%>').focus();
return false;

} }

<asp:UpdatePanel ID="UpdatePnl" runat="server" UpdateMode="Conditional">
        <ContentTemplate>     
            <ajaxToolKit:TabContainer runat="server" id="myTabs" CssClass="CustomTabStyle">
            <ajaxToolKit:TabPanel ID="pnlTab1" runat="server" HeaderText="Tab 1">                                                  
            <ContentTemplate> 
                <table> 
                    <tr>                           
                        <td>                 
                            <div class="Tab1">                     
                                <asp:Label ID="lblPnl1" runat="server"></asp:Label>                                                   
                            </div>                              
                        </td>
                    </tr>   
                </table> 
            </ContentTemplate>             
            </ajaxToolKit:TabPanel>

            <ajaxToolKit:TabPanel ID="pnlTab2" runat="server" HeaderText="Tab2">               
            <ContentTemplate>              
                <table>
                    <tr>
                        <td>
                            <div class="Tab2">                     
                                <asp:Label ID="lblPnl2" runat="server"></asp:Label>                       
                            </div>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
           </ajaxToolKit:TabPanel>
 </ajaxToolKit:TabContainer>
    </ContentTemplate>
</asp:UpdatePanel>

SO basically, how can i find the index of a TabPanel so that I can set the activeTab to the index found?所以基本上,我怎样才能找到 TabPanel 的索引,以便我可以将 activeTab 设置为找到的索引?

========================================================================= ==================================================== ========================

function setFocus() {
        var success = false;
        var tabInedx = 0;
        var tabs = $find("<%= myTabs.ClientID %>").get_tabs();
        for (; tabInedx < tabs.length; tabInedx++) {
            if (tabs[tabInedx].get_id() == "<%= pnlTab2.ClientID %>") {
                success = true;
                break;
            }
        }

        if (success) {
            alert("Tab2 index: " + tabInedx)
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM