问题描述
Hello Friendz,
我陷入了一个特殊的问题.
我的要求是,当用户登录客户端时,应该保存时间并将其显示在屏幕上.
因此,在我们的LMS Bangalore软件页面上,我编写了一个JavaScript,该JavaScript捕获客户端时间并将其存储在隐藏字段中.然后,单击登录按钮,我将其存储在Session ["Clienttime"]中,然后在打开页面时将其显示在Create Employee页面上.
这是我的JavaScript代码:
Hello Friendz,
I am stuck up with a peculiar problem.
My requirement is that when the user logs in the client side time should be saved and should be displayed on the screen.
So on our LMS Bangalore software''s page I have written a JavaScript which captures the client side time and stores it in a hidden field. Then on the click of the log in button I am storing it in the Session["Clienttime"] and then displays it on the Create Employee page when the page opens.
Here is my JavaScript code:
<script language="javascript" type="text/javascript">
function EncryptMD5()
{
var Pass = document.getElementById("<%=txtPassword.ClientID%>").value;
// Encrypte the password
if (Pass.length > 0 )
{
var MD5Hash = hex_md5(Pass);
var salt = document.getElementById("<%=SaltStr.ClientID%>").value;
MD5Hash = hex_md5(salt+MD5Hash);
document.getElementById("<%=HashPass.ClientID%>").value = MD5Hash;
document.getElementById("<%=txtPassword.ClientID%>").value = MD5Hash;
}
DisplayDateTime()
}
function DisplayDateTime()
{
var DateTime = new Date();
var strYear= DateTime.getYear();
var strMonth= DateTime.getMonth() +1;
var strDay = DateTime.getDate();
var strHours = DateTime.getHours();
var strMinutes = DateTime.getMinutes();
var strSeconds = DateTime.getSeconds();
var clientTime = strDay + "/" + strMonth + "/" + strYear + " " + strHours + ":" + strMinutes + ":" + strSeconds;
document.getElementById("<%=hfClientTime.ClientID%>").value = clientTime;
}
</script>
然后,我在登录按钮上单击以下按钮:
Session ["Clienttime"] = hfClientTime.Value.ToString();
在我的.aspx页面中,我调用javascript:
OnClientClick ="EncryptMD5()"
在我的员工页面上,我想显示时间,请执行以下操作:
lblTime.Text =会话["Clienttime"].ToString();
问题是我第一次登录时一切正常.但是,当我注销或关闭页面并再次登录时,尽管每次在登录按钮上分配时间值,我都发现会话已清除.
你能告诉我我要去哪里错吗?
谢谢你
Swapnil Borkar.
Then I do this on log in buttons click:
Session["Clienttime"] = hfClientTime.Value.ToString();
and in my .aspx page i call javascript:
OnClientClick="EncryptMD5()"
and on my employee page I want to display the time so do this:
lblTime.Text = Session["Clienttime"].ToString();
The problem is when I log for the first time everything works fine. But then when I log out or close the page and again logs in I find the session cleared despite evertime assigning the time value on the login buttons click.
Can u tell me where I am going wrong?
Thanking You
Swapnil Borkar.
推荐答案
这篇关于会话会自动清除.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!