Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Use Timer Contorl in asp.net

Use Timer Contorl in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rinki Mukheraji
    wrote on last edited by
    #1

    how use Timer Control in asp.net

    S S E 3 Replies Last reply
    0
    • R Rinki Mukheraji

      how use Timer Control in asp.net

      S Offline
      S Offline
      sumit7034
      wrote on last edited by
      #2

      Use Ajax to use timer control

      R 1 Reply Last reply
      0
      • R Rinki Mukheraji

        how use Timer Control in asp.net

        S Offline
        S Offline
        Sathesh Sakthivel
        wrote on last edited by
        #3

        Timer controls work well on an asp.net page. As a web page refreshes each time it is back, You should declare the time control as a static attribute of the page, as well as the timer event handler. protected System.Timers.Timer timer1; private int test; protected void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here test = 1; timer1.Interval = 1000; timer1.Start(); timer1.Enabled = true; } private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { test = test+1; lblCounter.Text = "count:"+test; }

        SSK. Anyone who says sunshine brings happiness has never danced in the rain.

        J 1 Reply Last reply
        0
        • S sumit7034

          Use Ajax to use timer control

          R Offline
          R Offline
          Rinki Mukheraji
          wrote on last edited by
          #4

          i was try but not work. please give me example.

          E 1 Reply Last reply
          0
          • R Rinki Mukheraji

            i was try but not work. please give me example.

            E Offline
            E Offline
            eyeseetee
            wrote on last edited by
            #5

            AjAX Toolkit[^]

            The answers posted by me are suggestions only and cannot be used in anyway against me.

            1 Reply Last reply
            0
            • S Sathesh Sakthivel

              Timer controls work well on an asp.net page. As a web page refreshes each time it is back, You should declare the time control as a static attribute of the page, as well as the timer event handler. protected System.Timers.Timer timer1; private int test; protected void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here test = 1; timer1.Interval = 1000; timer1.Start(); timer1.Enabled = true; } private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { test = test+1; lblCounter.Text = "count:"+test; }

              SSK. Anyone who says sunshine brings happiness has never danced in the rain.

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #6

              Vri SSK wrote:

              Timer controls work well on an asp.net page.

              No, they really don't. In your example every user will have the same timer :| A javascript timer will work, such as the one within the AJAX Toolkit. Please consider your answer to questions before posting them, if you're unsure its probably better to not bother posting.

              L 1 Reply Last reply
              0
              • R Rinki Mukheraji

                how use Timer Control in asp.net

                E Offline
                E Offline
                eyeseetee
                wrote on last edited by
                #7

                One problem I found on the timer control is that if I had code running on page load and the timer was set to update say eevry minute the code on the page load would run as well. This is a big drawback if you are using postback scripts etc

                The answers posted by me are suggestions only and cannot be used in anyway against me.

                1 Reply Last reply
                0
                • J J4amieC

                  Vri SSK wrote:

                  Timer controls work well on an asp.net page.

                  No, they really don't. In your example every user will have the same timer :| A javascript timer will work, such as the one within the AJAX Toolkit. Please consider your answer to questions before posting them, if you're unsure its probably better to not bother posting.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  J4amieC wrote:

                  f you're unsure its probably better to not bother posting

                  I'm never 100% sure.. ..even an answer that isn't 100% can give you a pointer in the right direction. Sometimes such an answer becomes the base for an entire discussion. It does happen that we generate an adequate answer as a group, because we interact. FWIW; you can make the code user-specific :)

                  J 1 Reply Last reply
                  0
                  • L Lost User

                    J4amieC wrote:

                    f you're unsure its probably better to not bother posting

                    I'm never 100% sure.. ..even an answer that isn't 100% can give you a pointer in the right direction. Sometimes such an answer becomes the base for an entire discussion. It does happen that we generate an adequate answer as a group, because we interact. FWIW; you can make the code user-specific :)

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #9

                    eddyvluggen wrote:

                    ..even an answer that isn't 100% can give you a pointer in the right direction.

                    And a stupid answer like the one given can lead you down the garden path, round the block and back again. In addition, im 99% sure the OP wanted a timer on the client not the server. He may not have specified that, but after years of answering questions on forums like CP, you can generally tell.

                    eddyvluggen wrote:

                    FWIW; you can make the code user-specific

                    Not with a static Timer you cant. You may wish to read up on the static keyword.

                    L 1 Reply Last reply
                    0
                    • J J4amieC

                      eddyvluggen wrote:

                      ..even an answer that isn't 100% can give you a pointer in the right direction.

                      And a stupid answer like the one given can lead you down the garden path, round the block and back again. In addition, im 99% sure the OP wanted a timer on the client not the server. He may not have specified that, but after years of answering questions on forums like CP, you can generally tell.

                      eddyvluggen wrote:

                      FWIW; you can make the code user-specific

                      Not with a static Timer you cant. You may wish to read up on the static keyword.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      J4amieC wrote:

                      You may wish to read up on the static keyword.

                      Will do. I assumed that the component is simply shared among the users. Am I mistaken?

                      J4amieC wrote:

                      And a stupid answer like the one given can lead you down the garden path, round the block and back again.

                      Thanks for the warning :)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups