When I use DateTime.Now I get the date and time from the server point of view. Is there any way to get the client date and time in ASP.NET?
When I use DateTime.Now I get the date and time from the server point
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What I’d do is create a hidden input field and then wire a Javascript routine to the onsubmit event for the form. This routine would populate the hidden field with the time on the client machine.
The hidden field can used with ASP.NET by using the HTML control ‘HtmlInputHidden’ class. You just give you input control a runat=’server’ attribute like any other server side control.
The server can then read out this time when the form posts back. You could even wrap this up in a server control if you need to do this in a number of places.
Alternatively, you could do this with AJAX but the implementation will depend on which library you use.