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. Asp.net Timer

Asp.net Timer

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nethelp
4 Posts 4 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.
  • N Offline
    N Offline
    NewToAspDotNet
    wrote on last edited by
    #1

    Hi All, Im triyng to use the System.Timers.Timer control in my page. In de button click eventhandler i have this code: System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Interval = 1000; myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed); myTimer.Enabled = true; protected void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //do test Label1.Text = "a"; } The problem is that nothing happens ofter clicking the button. What is wrong here? Thanks.

    C A 2 Replies Last reply
    0
    • N NewToAspDotNet

      Hi All, Im triyng to use the System.Timers.Timer control in my page. In de button click eventhandler i have this code: System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Interval = 1000; myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed); myTimer.Enabled = true; protected void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //do test Label1.Text = "a"; } The problem is that nothing happens ofter clicking the button. What is wrong here? Thanks.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      NewToAspDotNet wrote:

      What is wrong here?

      You don't understand how web applications work. There is no state. They are stateless. The page exists only for the briefest moment while the request is handled. After that it is unloaded from memory. Your timer now has nothing to time.

      Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

      V 1 Reply Last reply
      0
      • C Colin Angus Mackay

        NewToAspDotNet wrote:

        What is wrong here?

        You don't understand how web applications work. There is no state. They are stateless. The page exists only for the briefest moment while the request is handled. After that it is unloaded from memory. Your timer now has nothing to time.

        Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        His username is 'NewToAspDotnet' and he has been a member since 2004. And check out his profile page http://www.codeproject.com/script/Membership/Profiles.aspx?mid=1251994[^]. He has asked a question on his own profile.

        Vasudevan Deepak Kumar Personal Homepage
        Tech Gossips
        All the world's a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts... --William Shakespeare

        1 Reply Last reply
        0
        • N NewToAspDotNet

          Hi All, Im triyng to use the System.Timers.Timer control in my page. In de button click eventhandler i have this code: System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Interval = 1000; myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed); myTimer.Enabled = true; protected void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //do test Label1.Text = "a"; } The problem is that nothing happens ofter clicking the button. What is wrong here? Thanks.

          A Offline
          A Offline
          AlexeiXX3
          wrote on last edited by
          #4

          If you wanna use timers, take a look at the AjaxControlToolKit The have a timercontrol that behaves just like the timer in windows apps

          Alexei Rodriguez

          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