ASP.NET - Javascript timeOut Warning based on sessionState timeOut in web.config

后端 未结 6 1620
囚心锁ツ
囚心锁ツ 2020-12-06 08:33

Problem: I am looking to create a time-out warning message on an asp.net page with a c# code behind based off my webconfig sessionState TimeOut Attribute.

Code on w

6条回答
  •  情话喂你
    2020-12-06 09:10

    I was not able to get FishbasketGordo's code to work because the Web Method call kept passing the Boolean value "false" as the onsuccess method. After much research I made the following changes.

                $(function () {
                    var isTimeout = false;
                    var callback = function (isTimeout) {
                        if (isTimeout) {
                            // Show your pop-up here...
                            alert("You have timed out");
                        }
                    };
    
                    var failure = function () {
                        alert("Problem with Server");
                    };
    
                    setInterval(
                            function () {
                                // Don't forget to set EnablePageMethods="true" on your ScriptManager.
                                PageMethods.HasSessionTimedOut(callback,failure);
                            }, 30000
                    );
                });
    

提交回复
热议问题