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. how to display timer dynamically in a asp.net form?

how to display timer dynamically in a asp.net form?

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nettoolstutorial
4 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    balaji t
    wrote on last edited by
    #1

    hi folks, I wud like to display running time in my page using javascript.For that i ve used the following client side function. <form name="counter"><input type="text" size="8" name="d2"></form> <script type="text/javascript"> var milisec=0 var seconds=120 // document.counter.d2.value=0 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1) { milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",1000) } display() ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value. for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Thanx in advance

    T.Balaji

    M 1 Reply Last reply
    0
    • B balaji t

      hi folks, I wud like to display running time in my page using javascript.For that i ve used the following client side function. <form name="counter"><input type="text" size="8" name="d2"></form> <script type="text/javascript"> var milisec=0 var seconds=120 // document.counter.d2.value=0 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1) { milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",1000) } display() ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value. for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Thanx in advance

      T.Balaji

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      Use RegisterClientVariable

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      B 1 Reply Last reply
      0
      • M Manas Bhardwaj

        Use RegisterClientVariable

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        B Offline
        B Offline
        balaji t
        wrote on last edited by
        #3

        can u send me the code?

        T.Balaji

        M 1 Reply Last reply
        0
        • B balaji t

          can u send me the code?

          T.Balaji

          M Offline
          M Offline
          Manas Bhardwaj
          wrote on last edited by
          #4

          At Server Side:

          ClientScript.RegisterHiddenField("someHiddenField", "120");

          At Client Side:

          var someValue = document.getElementById("someHiddenField");

          Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

          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