473,385 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Insert Client System Date and Time on aspx page

112 100+
Hi,
I have a label called label1 and i want to display client system date and time on it.

Thanks
Jan 3 '08 #1
4 1903
this.Label.Text=DateTime.Today.ToString();
Jan 3 '08 #2
nukefusion
221 Expert 100+
this.Label.Text=DateTime.Today.ToString();
Seeing as code in the code-behind is run on the server, wouldn't that display the webservers date and time?

If you want to show the client's date and time you will need to use something like javascript.
Mar 19 '08 #3
check this URL for java script time


http://www.web-source.net/web_develo...cript_date.htm
Mar 19 '08 #4
balabaster
797 Expert 512MB
Seeing as code in the code-behind is run on the server, wouldn't that display the webservers date and time?

If you want to show the client's date and time you will need to use something like javascript.
Does it need to be a live clock? If so, you'd need to do a JavaScript to update a textbox on timer event. If not, you can use the following script:

Expand|Select|Wrap|Line Numbers
  1. <script type="Text/Javascript">
  2. <!--
  3. function displayDate(elem){
  4. var obj = document.getElementById(elem);
  5. var time = new Date();
  6. var d = time.getDay();
  7. var M = time.getMonth();
  8. var y = time.getYear();
  9. var h = time.getHours();
  10. var m = time.getMinutes();
  11. var s = time.getSeconds();
  12. h = (h<10? '0': '') + h;
  13. m = (m<10? '0': '') + m;
  14. s = (s<10? '0': '') + s; 
  15. var t = (h<12? 'AM': 'PM');
  16. obj.value = d + '/' + M + '/' + y + ' ' + h + ':' + m + ':' + s + ' ' + t;
  17. }
  18. -->
  19. </script>
Call this from the onLoad event of your page or the onInit event of your textbox or label. Remember that this must be run as a client side script though.

Expand|Select|Wrap|Line Numbers
  1. <body onload="displayDate('datedisplay');">
  2. <input type="text" id="datedisplay" />
  3. </body>
Mar 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: SSP | last post by:
Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. Thanks in advance. SSP
9
by: Allen Davis | last post by:
Is there no way in ASP.NET to retrieve the client's timezone (or even local time, I'd settle for that) and passing it to the server? There must be a way of determining the timezone from which the...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
3
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi, We are writing a Web SSO service for all of our websites through Forms Authentication. We also want to provide our websites with the ability to protect different parts of their website and...
4
by: Olivier Matrot | last post by:
Hello, I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. This ends with the following exception : <Source>System</Source> <StackTrace...
1
by: Olivier Matrot | last post by:
I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. After further analysis, it appears that : - There is 2 disctinct session for the...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.