Results 1 to 12 of 12

Thread: [RESOLVED] Server Clock JS

  1. #1

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Resolved [RESOLVED] Server Clock JS

    Hey guys,

    Does anyone know of good JS function to display the server clock to the user?
    i need it to display the clock dynamically, i tried to use ASP.NET + AJAX but after few hours the browser crash with C++ error (memory leak?)

    Regards!
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Server Clock JS

    Hey,

    Can you show the code that you were using? Might be that we could get it working.

    Gary

  3. #3

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Server Clock JS

    i just added label and timer to updatepanel and used the tick event to update the time every second..
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Server Clock JS

    Hey,

    But, depending on exactly how you have implemented this, over a period of time, this could lead to problems with incorrectly disposed of items.

    Gary

  5. #5

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Server Clock JS

    the only code that i added to the Tick event was
    Code:
    Label1.Text = DateTime.Now
    should i dispose it somehow?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Server Clock JS

    That's a terrible way to show a clock. You're consuming server resources for no good reason!

    You should use any existing Javascript clock script but modify it to start at a time that you specify. You can do this by generating the Javascript's startup bit from the codebehind and concatenating the server's current time. When the page loads, the javascript can use its own timer functions to increment the time on the page, but the point is that you only 'write' the time to the page once.

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Server Clock JS

    Seems like there are lots of example of doing this over the interweb though...

    Here is just one:

    http://basgun.wordpress.com/2008/02/...x-updatepanel/

    Gary

  8. #8

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Server Clock JS

    the only difference from what i did is that the author used JS timer and i used the timer from the toolbox (which is also JS timer i guess), so what do i need to understand from this fact? the toolbox timer has memory leak??
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Server Clock JS

    Hey,

    No, I certainly don't think that there is a memory leaker in the Timer.

    I think the problem that you are seeing is as of a result of your posting back to the server (albeit, a partial postback), I am guessing, every second.

    Gary

  10. #10

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Server Clock JS

    thanks mendhak, that thought passed my mind also!
    i used to use JS clock with my old website but it didn't worked well with google's chrome browser, i'll search for the clock that suite my need in the link you supplied
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  11. #11

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Server Clock JS

    so i guess sticking with JS is what i need for my clocks usage :B thanks guys!
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Server Clock JS

    Hey,

    For some things, you really need to stick with JavaScript, it is the only thing that really makes sense. Bottom line is, if you don't need to get information from the server, then stick in the client.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width