Discuss How to display message on Home Page automatically in the .Net Development forum on Dev Shed. How to display message on Home Page automatically .NET development forum discussing all .NET derivatives including C#, VB.NET, ASP.NET, ADO.NET and more. Learn the ins and outs of using the .NET framework.
Posts: 18
Time spent in forums: 7 h 49 m 19 sec
Reputation 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)
Posts: 412
Time spent in forums: 5 Days 2 h 6 m 13 sec
Reputation Power: 143
Quote:
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.
Posts: 305
Time spent in forums: 5 Days 18 h 57 m 35 sec
Reputation Power: 0
Quote:
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)