Click here to Skip to main content
15,439,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
--------------------------USE OF TIMER CONTROL IN ASP.NET(VB)---------------------------------------------------
<table runat ="server" style="width: 818px" >
    <tr>
    <td>
        &nbsp;</td>
    <td>
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1000">
            </asp:Timer>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="UpdatePanel1 not refreshed yet."></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label2" runat="server" Text="UpdatePanel2 not refreshed yet."></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>


    </td>
    <td>
        &nbsp;</td>
    <td>
        &nbsp;</td>
    <td>
        &nbsp;</td>
    </tr>

</table>

VB
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = "UpdatePanel1 refreshed at: " & _
         DateTime.Now.ToLongTimeString()
        'Label2.Text = "UpdatePanel2 refreshed at: " & _
        '  DateTime.Now.ToLongTimeString()


        Dim tickCount As Integer = 0
        If ViewState("TickCount") IsNot Nothing Then
            tickCount = CType(ViewState("TickCount"), Integer)
        End If
        tickCount += 1
        ViewState("TickCount") = tickCount    ' Decide whether to disable the timer.
        If tickCount > 120 Then
            Label1.Text = "Time is Over!!!!!!!"
            Timer1.Enabled = False
        End If

    End Sub
Posted
Updated 30-May-11 7:44am
v3

You are trying to mentioned only Code and have not mentioned anything more. is it your question? you've just posetd another question there[^] in same manner without any specific details.
if you have any query so please mention it otherwise posting only code will not help you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900