客户日期和时间 [英] client date and time

查看:97
本文介绍了客户日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得客户的时间?我的主页中有一个gridview,其中显示从我的数据库中检索到的所有详细信息。如果客户端的时间大于输入的时间,我想将我的表的状态更新为过期。我有一个webform,这是一个申请表,我接受用户的时间并在我的主页上显示。



我试过用这个:

在Login.aspx中:

How to get Client's time? I have a gridview in my Home page in which i am displaying all the details retrieved from my database. I want to update my table's status to expired if the client's time is greater than entered time. I have a webform which is a Request Form in which i am accepting time from the user and displaying it on my homepage.

I tried using this:
In Login.aspx :

<script type="text/javascript">

            window.onload = function () {

            var newdate = new Date();

            var hdnfield = document.getElementById('<%=hdnClientDate.ClientID%>');

                hdnfield.value = newdate.toLocaleString();

        }

    </script>







<asp:HiddenField ID="hdnClientDate" runat="server" OnValueChanged="hdnClientDate_OnInit" />





在Login.aspx.cs中:



In Login.aspx.cs:

protected void hdnClientDate_OnInit(object sender, EventArgs e)    {

        Session["hdnClientDate"] = hdnClientDate.Value;

    }// saving the time in session

推荐答案

Javascript是一种客户端脚本语言,因此您可以使用javascript来获取浏览器的日期和时间。只需谷歌搜索它,你会发现很多样本。但是如果你不想使用javascript,那么你也可以使用ASP.Net来做。以下链接可以帮助您:

http://weblogs.asp.net/mikebosch/archive/2007/11/15/getting-the-client-browsers-date-and-time-with-asp -net.aspx [ ^ ]
Javascript is a client side scripting language, so you can use javascript to get the date and time of the browser. Just google for it and you will find a lot of samples. But if you don't want to use javascript, then you can also do it using ASP.Net. The following link may help you:
http://weblogs.asp.net/mikebosch/archive/2007/11/15/getting-the-client-browsers-date-and-time-with-asp-net.aspx[^]


这篇关于客户日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆