JavaScript to Show time countdown display after .net session timeout
I would like to know that, is it possible for me to have a javascript which will display the time countdown minutes automatically after the net session timeout gets over. Can any body tell me that how can i do it? Does any body have any idea about the above issue? Kindly provide me the correct logical solution for the above issue.
Re: JavaScript to Show time countdown display after .net session timeout
Just follow teh below steps mention.
Quote:
<script type="text/javascript">
var sessionTimeout = "<%= Session.Timeout %>";
function DisplaySessionTimeout()
{
//assigning minutes left to session timeout to Label
document.getElementById("<%= lblSessionTime.ClientID %>").innerText =
sessionTimeout;
sessionTimeout = sessionTimeout - 1;
//if session is not less than 0
if (sessionTimeout >= 0)
//call the function again after 1 minute delay
window.setTimeout("DisplaySessionTimeout()", 60000);
else
{
//show message box
alert("Your current Session is over.");
}
}
</script>
Hope so it may help you out.:thumbup1:
Re: JavaScript to Show time countdown display after .net session timeout
The best advice would probably be to ask the users to close the browser window once they're done. With the use of session-cookies, the session will automatically end when the browser is closed or otherwise on a 30 minute timeout. Since there by default is no interaction between the browser and the server once a page is loaded, you would have to have a javascript contact the server in the background on forms-pages to refresh the session.
Re: JavaScript to Show time countdown display after .net session timeout
Begin by creating a new ASP.NET Server Control project called SessionTimeoutTool. This will generate both a project and a solution for you. Add a second ASP.NET Web project to the solution called TestTimeoutTool. Open the web.config file for TestTimeoutTool and add a sessionState element in order to set the session timeout period. For the purposes of testing this control, it is advisable to set this attribute to something small.
Quote:
<system.web>
<sessionState timeout="2" mode="InProc"/>
</system.web>
This establishes the control development environment.
Rename the default class in the SessionTimeoutTool project by right clicking on the default class in the Solution Explorer and renaming the file from ServerControl1.cs to TimeoutWatcherControl. The IDE will take care of renaming your class for you. The TimeoutWatchControl class comes with the Text property and the RenderContents already implemented for you by the IDE. You may delete these. You may also safely remove the ToolboxData and DefaultProperty attributes that decorate your class declaration.
Quote:
namespace SessionTimeoutTool
{
public class TimeoutWatcherControl : WebControl
{
}
}