0

在我的表单中,我有一个位于 radajaxpanel 内的计时器。此计时器用于每 1 分钟自动保存一次表单。

现在我的问题是每当调用自动保存时,它都会更新会话超时。但我需要的是在空闲一个小时后显示通知(要求用户更新会话,否则我将注销用户)并忽略自动保存会话超时更新。

更新:

这是代码

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
    <asp:Timer ID="Timer1" runat="server"  OnTick="AutoSaveNotificationCallBackUpdate" Interval="60000" />

</telerik:RadAjaxPanel>

AutoSaveNotificationCallBackUpdate 将进行回发,从而重置我的会话超时。

4

2 回答 2

0

您可以在客户端使用计时器。这是示例代码,不完全是,但可以帮助您弄清楚要做什么。

var timer;

function initTimer(){
    clearTimeout(timer);
    timer = setTimeout(function(){
         if(!confirm("Do you want to continue?")) {
              // do some postback to logout, e.g. trigger a logout button 
         }
         else 
              initTimer();
    }, 36000);
}

// in this case, if user does not click in an hour, 
// the confirm dialog will display.
document.onclick = function(){
    // reset the timer every time user click on page
    initTimer();
});

window.onload = function(){
    initTimer();
});
于 2013-01-03T15:02:32.413 回答
0

您可以将以下代码保存到interval.js

if(window.intervals)
    ;
else {
    function Interval() {
        var instance=this;
        var a=[];

        Interval.toString=function () {
            return '[Interval]';
        }

        instance.toString=function () {
            return '[object Interval]';
        }

        instance.Register=function (x, code, delay) {
            a[x]=setInterval(code, delay);
        }

        instance.Deregister=function (x) {
            if(x in a)
                clearInterval(a[x]);
        }
    }

    window.intervals=new Interval();
}

然后将其包含在

<script src='interval.js'></script>

或者

<script src='YourSubfolder/interval.js'></script>

在您的页面中,您可以注册一个间隔:

intervals.Register('YourIntervalName', YourMethod, millisecondsInterval);

或注销它:

intervals.Deregister('YourIntervalName');
于 2013-01-03T13:03:06.423 回答