Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

asp.net date/time on master page

Options
  • 05-07-2008 12:46pm
    #1
    Closed Accounts Posts: 317 ✭✭


    Hi,

    using vb.bet/asp.net.
    I'm using a masterpage and I'd like to show the current date time (including seconds) on the header.

    is it possible to have a label of somesort that updates every second ?
    I have one but you have to refresh the page if you want to see the seconds change.

    Cheers


Comments

  • Closed Accounts Posts: 5,284 ✭✭✭pwd


    yes you need to use ajax - or you could do it with silverlight, though that needs a plugin on the client side. Download asp.net ajax extensions.


  • Closed Accounts Posts: 317 ✭✭tiptap


    pwd wrote: »
    yes you need to use ajax - or you could do it with silverlight, though that needs a plugin on the client side. Download asp.net ajax extensions.

    Thanks for the tip.
    I have download extensions and I can see ajax extensions in the control toolbox.

    There is an option for "Timer", is that what I have to use.
    I put that on the form and it said I needed a script manager, so I saw that in the control box and added that also.
    Nothing is appearing though on the web form.

    I'm sure I'm missing something very obvious here!


  • Closed Accounts Posts: 5,284 ✭✭✭pwd




  • Closed Accounts Posts: 317 ✭✭tiptap


    pwd wrote: »


    perfect, thanks your help pal


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Do you need Server time or Client time displayed on the page?


  • Advertisement
  • Closed Accounts Posts: 317 ✭✭tiptap


    Evil Phil wrote: »
    Do you need Server time or Client time displayed on the page?

    Hi,

    I need server time.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    You'll need to use Ajax then. Be weary of calling a method in your code behind as it can fire the page's event cycle and you could end up with a PageRequestManagerServerErrorException. Best bet is to include web service in your project and call a method on that.


  • Closed Accounts Posts: 81 ✭✭dzy


    I'd stay away from the Ajax. It doesn't make sense to fetch the server time every second when you know it'll just be a second later than what it was when you requested it a second ago. I'd send the server time down in the response and then update it client side with some Javascript.


  • Registered Users Posts: 2,494 ✭✭✭kayos


    dzy wrote: »
    I'd stay away from the Ajax. It doesn't make sense to fetch the server time every second when you know it'll just be a second later than what it was when you requested it a second ago. I'd send the server time down in the response and then update it client side with some Javascript.

    I would agree with this, your talking about making 60 calls a minute per session thats a hell of a lot of traffic as .NET AJAX still posts back the full page on an AJAX postback. Its a lot of work on the server for nothing other than a clock. Any way if this is accessable via the internet the time it would take the response to make its way to the client you are going to be displaying the wrong time anyway.

    Much better off getting the time on the initial page load and then as dzy said update it on the client side with some JS.


Advertisement