如何通过javascript在asp.net中找到会话提醒时间? [英] How to findout session remining time in asp.net through javascript?

查看:71
本文介绍了如何通过javascript在asp.net中找到会话提醒时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中尝试了以下代码,但它向我显示错误。类似于

I tried below code in master page but it shows me error.Like

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).



我的代码在这里:


My code is here:

<script type="text/javascript" language="javascript">
        var sessionTimeout = "<%= Session.Timeout %>";
        function DisplaySessionTimeout() {
            alert(sessionTimeout);
            //if session is not less than 0
            if (sessionTimeout >= 0)
            //call the function again after 1 minute delay
                window.setTimeout("DisplaySessionTimeout()", 5000);
            else {
                //show message box
                alert("Your current Session is over.");
            }
        }
    </script>

推荐答案

由于控件包含代码块(即<%...%>),因此无法修改Controls集合。 [ ^ ]


如果您的javascript位于页面的head部分,请尝试将其放在body标签的末尾...
if your javascript is in the head section of the page, try placing it at the end after body tag...


这篇关于如何通过javascript在asp.net中找到会话提醒时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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