软件下载 | 资讯教程 | 最近更新 | 下载排行 | 一键转帖 | 发布投稿
您的位置:最火下载站 > 网络编程 > ASP教程 > 如何让ajax的Tabcontainer自动轮换显示

如何让ajax的Tabcontainer自动轮换显示

  1.首先要加入一个ajax的Timer,把Timer放到updatepanel内,html代码如下:

以下为引用的内容:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:TabContainer ID="TabContainer1" runat="server" Height="233px" Width="513px" 
ActiveTabIndex="0" AutoPostBack="True"> 
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1"> 
<HeaderTemplate>First</HeaderTemplate> 
<ContentTemplate>Test1</ContentTemplate> 
</cc1:TabPanel> 
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2"> 
<HeaderTemplate>Second</HeaderTemplate> 
<ContentTemplate>afdsfsda</ContentTemplate>
</cc1:TabPanel> 
<cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3"> 
<HeaderTemplate>Third</HeaderTemplate> 
<ContentTemplate>fadsfsad</ContentTemplate> 
</cc1:TabPanel>
</cc1:TabContainer>
<asp:Timer ID="Timer1" runat="server" Interval="2000">
</asp:Timer>
</ContentTemplate>
<Triggers> 
<asp:AsyncPostBackTrigger ControlID="TabContainer1" />
</Triggers>
</asp:UpdatePanel>

  注意Tabcontainer的autopostback必须为true

  2.然2.然后在对应的timer事件中写入如下代码:

以下为引用的内容:
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim i As Integer = 0
If Session("t") IsNot Nothing Then
i = Session("t")
End If
If i <= 2 Then ‘如果有4个轮换,则要把2改为3
TabContainer1.ActiveTabIndex = i
i += 1
Else
TabContainer1.ActiveTabIndex = 0
i = 0
End If
Session("t") = i
End Sub

    相关阅读
    网友评论