Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8253649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:56:54+00:00 2026-06-08T00:56:54+00:00

Basically I’m simply trying to implement a timer control that will swap banners for

  • 0

Basically I’m simply trying to implement a timer control that will swap banners for me and then update in an update panel. However the timer only affects my page once, and appears to be firing twice(I put a label on the form and attempted to increment by one each time it would update, and it jumped to 2 then stopped).

                   <asp:ContentPlaceHolder ID="cphHead" runat="server">


                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:Timer ID="Timer1" runat="server" Interval="6000" OnTick="Timer1_Tick">
                    </asp:Timer>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="Timer1" />
                        </Triggers>
                        <ContentTemplate>
                            <asp:Image ID="Image1" runat="server" ImageUrl="~/images/banner_2.jpg" />

                            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                        </ContentTemplate>
                    </asp:UpdatePanel>


                </asp:ContentPlaceHolder>

and there is my code behind

Partial Class ASPTravel
    Inherits System.Web.UI.MasterPage

    Private intnum As Integer = 0
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    End Sub



    Protected Sub LoginStatus1_LoggingOut(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles LoginStatus1.LoggingOut
        Session.Abandon()
    End Sub




    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

            intnum = intnum + 1
            Label1.Text = CStr(intnum)
            ' If intnum = 0 Then
            '  Image1.ImageUrl = "~/images/banner_1.jpg"
            '  intnum = 1
            ' Else
            '  Image1.ImageUrl = "~/images/banner_2.jpg"
            'End If
            Dim n As Integer = New Random().Next(1, 2)
            Image1.ImageUrl = "~/images/banner_" + n.ToString() + ".jpg"



    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:56:55+00:00Added an answer on June 8, 2026 at 12:56 am

    Remove the Handles Timer1.Tick from your code behind and it will works fine.I have checked it.
    like this.

     Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
    

    Reference: http://forums.asp.net/t/1642896.aspx/1

    also user viewstate instead of variables. Variables are initialized on every postback in asp.net. So instead of saving value in a variable Private intnum As Integer = 0 save it in a View state like this

    ViewState["intnum"] = 0
    

    and in your timer click event.

    ViewState["intnum"]= (int) ViewState["intnum"] + 1
    Label1.Text = CStr(ViewState["intnum"])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.
Basically I’ve heard that certain conditions will cause .NET to blow past the finally
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
Basically, I'm trying to compile CEF on VS2008 EE. The IDE complains that it
Basically I've made a form in Cakephp 2.1 with a jQuery button that appends
Basically from C++ FAQ I learned that: A virtual function allows derived classes to
Basically, what I'm trying to create is a page of div tags, each has
Basically from a database I am getting data that is formatted like this nameofproject101
Basically what I'm trying to do is make a very simple vertical bullet projectile
Basically I have an iframe loaded that is accessed from the parent whenever it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.