Below is the sample code of one the way achieving this, sample code will just to give you an idea. Here idle time for testing is 3 second (you can change that). This sample got one text box if user does not click on it with 3 sec interval user will be logged out.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script>
var logoutUser = false;
var timeoutHnd = null;
var logouTimeInterval = 3000;// Three Second
function onuser_activite(){
if(logoutUser){
alert("You Session Expired");
window.location.href="/KB/answers/Logout.aspx";
}
else{
ResetLogOutTimer();
}
}
function OnTimeoutReached(){
logoutUser = true;
}
function ResetLogOutTimer(){
clearTimeout(timeoutHnd);
// set new timer
timeoutHnd = setTimeout('OnTimeoutReached();',logouTimeInterval);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="tbxarea" runat="server" title="Write your name here"></asp:TextBox>
</div>
</form>
<script>document.body.onclick = onuser_activite;
timeoutHnd = setTimeout('OnTimeoutReached();',logouTimeInterval);
</script>
</body>
</html>