我可以在页面上显示计时器吗 [英] can i show the timer in my page

查看:87
本文介绍了我可以在页面上显示计时器吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中是否有任何方法可以计算从登录到注销的时间
我也想在登录和注销之前从00:00开始在我页面中的计时器
我需要在我的asp页面中显示的计时器,不想显示datetime.现在,我需要从00:00到直到logout

is there any way to count the time from login to logout in c#
also i wants to so the timer in my page from 00:00 when login and upto logout
i need the timer with display in my asp page, don''t want to show datetime.now, i need from 00:00 to untill logout

推荐答案

您好,
您可以使用代码项目上的最佳示例来跟踪用户的登录和注销时间:
跟踪用户在您网站上的登录/注销时间
Hi,
You can keep track of login and logout times of user for that use a best example on code project:
Tracking users login/logout times on your site


在母版页上使用此脚本
JavaScript计时器
Use this script on master page
Javascript Timer




使用javascript,您可以获取登录的datetime.将其存储在变量中.调用Java脚本方法一段时间..say1min,



Using javascript, you can get the logged in datetime.Store it in variable.Call a java script method for some interval..say 1min ,

log time = nowdate_time - logged in datetime.



喜欢:



Like:

<body onload="updateClock(); setInterval(''updateClock()'', 1000 );">





function updateClock ()
{
  var Loggeddatetime = new Date ();
 
  var LoggedHours = Loggeddatetime.getHours ();
  var LoggedMinutes = Loggeddatetime.getMinutes ();
  var LoggedSeconds = Loggeddatetime.getSeconds (); 

  // Pad the minutes and seconds with leading zeros, if required
  LoggedMinutes = ( LoggedMinutes < 10 ? "0" : "" ) + LoggedMinutes;
  LoggedSeconds = ( LoggedSeconds < 10 ? "0" : "" ) + LoggedSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( LoggedHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  LoggedHours = ( LoggedHours > 12 ) ? LoggedHours - 12 : LoggedHours;

  // Convert an hours component of "0" to "12"
  LoggedHours = ( LoggedHours == 0 ) ? 12 : LoggedHours;

  // Compose the string for display by calculating the difference 
  //var currentTimeString 

  // Update the time display
  document.getElementById("<%=lblDateTime1.ClientID %>").innerHTML = currentTimeString;
  

}



希望这会有所帮助.



Hope this helps.


这篇关于我可以在页面上显示计时器吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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