admin管理员组文章数量:1323021
How would I get the ActiveTabIndex from TabContainer when the user selects a tab? I've tried the following but does not work.
<script type="text/javascript">
function TabChange() {
var tc = document.getElementById("TabContainer1")
alert(tc.ActiveTabIndex);
}
</script>
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="300px"
Width="300px" CssClass="MyTabStyle" OnClientActiveTabChanged="TabChange">
<asp:TabPanel runat="server" HeaderText="First" ID="TabPanel1">
<ContentTemplate>
<h1>
Tab 1
</h1>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server" HeaderText="Second">
<ContentTemplate>
<h1>
Tab 2
</h1>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
How would I get the ActiveTabIndex from TabContainer when the user selects a tab? I've tried the following but does not work.
<script type="text/javascript">
function TabChange() {
var tc = document.getElementById("TabContainer1")
alert(tc.ActiveTabIndex);
}
</script>
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="300px"
Width="300px" CssClass="MyTabStyle" OnClientActiveTabChanged="TabChange">
<asp:TabPanel runat="server" HeaderText="First" ID="TabPanel1">
<ContentTemplate>
<h1>
Tab 1
</h1>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server" HeaderText="Second">
<ContentTemplate>
<h1>
Tab 2
</h1>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Share
Improve this question
asked Oct 31, 2012 at 13:03
Troy MitchelTroy Mitchel
1,81013 gold badges51 silver badges89 bronze badges
2
- did you check this? stackoverflow./questions/6905899/… – ahaliav fox Commented Oct 31, 2012 at 13:18
- @ahaliav yes that works to my expectations. thanks. if you put in answer then i can mark as answered. – Troy Mitchel Commented Oct 31, 2012 at 13:28
1 Answer
Reset to default 5ASPX:
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" OnClientActiveTabChanged="clientActiveTabChanged">
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="Test1">
<ContentTemplate>Test1</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="Test2">
<ContentTemplate>Test2</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel3" runat="server" HeaderText="Test3">
<ContentTemplate>Test3</ContentTemplate>
</ajaxToolkit:TabPanel>
JS:
<script type="text/javascript">
function clientActiveTabChanged(sender, args) {
alert(sender.get_activeTabIndex());
}
本文标签: aspnetGet ActiveTabIndex from Ajax TabContainer using JavascriptStack Overflow
版权声明:本文标题:asp.net - Get ActiveTabIndex from Ajax TabContainer using Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742111760a2421288.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论