#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    305
    Rep Power
    0

    How to display message on Home Page automatically


    Hi everyone,

    I would like to display "We are open" on the Home Page (asp.net 4.0) when the time is 9am automatically.

    And then I would like to display "We are close" on the Home Page (asp.net 4.0) when the time is 5pm automatically.

    And then the next 9am, display "We are open" on the Home Page automatically,

    And then the next 5pm, display "We are close" on the Home Page automatically, ..., and so on.

    Can I make this to work ? If yes, please let me know what are the search keyword(s) so that I can search the internet by myself.

    Thanks,

    May

    Comments on this post

    • MBirchmeier agrees : Thank you for changing the way you post, to look for ways to learn instead of just asking for the answer
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    18
    Rep Power
    0
    without using ajax, the contents of your page are refreshed only when there's any roundtrip to server. If you are periodically making ajax calls to server you can do the 'open/close' stuff even if there's no activity form user's side..

    1) on page_load check if time is 9AM or 6PM and set the text of a label as 'we are open' or close respectively

    2) On clients side.. After every fixed interval (say 5 mins) make ajax calls to server.. server would return the current time, javascript checks and if conditions fall true, it updates the text of the said label to 'we are open/close'


    One thing though, wen u say 9 AM, do you mean 9 am your server time or 9AM the time at visitor's place?? you gonna have to take care of that as well if your website is intended for users from other countries as well, (which i feel is not the case here though)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Charlotte
    Posts
    412
    Rep Power
    144
    Originally Posted by cchy1988
    One thing though, wen u say 9 AM, do you mean 9 am your server time or 9AM the time at visitor's place?? you gonna have to take care of that as well if your website is intended for users from other countries as well, (which i feel is not the case here though)
    Not even in different countries is that an issue.
    Here in the U.S., we have 4 different time zones. So if your server is on the East Coast, the time will be different if it is on the west coast.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,609
    Rep Power
    1945
    Were just thinking if there was any physical "location" or if it is only web-based.

    If there is a physical location, that could be in the east, while the server (time) is in the middle and the visitor is at the west. Which time to use

    To answer OP questions, I suggest you take a look at this page
    http://msdn.microsoft.com/en-us/library/system.datetime.aspx

    The terms at that page are also (more or less) used in other languages, including javascript (AJAX) suggested by cchy1988.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    305
    Rep Power
    0
    Originally Posted by cchy1988
    without using ajax, the contents of your page are refreshed only when there's any roundtrip to server. If you are periodically making ajax calls to server you can do the 'open/close' stuff even if there's no activity form user's side..

    1) on page_load check if time is 9AM or 6PM and set the text of a label as 'we are open' or close respectively

    2) On clients side.. After every fixed interval (say 5 mins) make ajax calls to server.. server would return the current time, javascript checks and if conditions fall true, it updates the text of the said label to 'we are open/close'


    One thing though, wen u say 9 AM, do you mean 9 am your server time or 9AM the time at visitor's place?? you gonna have to take care of that as well if your website is intended for users from other countries as well, (which i feel is not the case here though)
    Thanks for everyone's help!

    I mean 9am on my server time.

    Thanks again!

    May

IMN logo majestic logo threadwatch logo seochat tools logo