Click here to Skip to main content
15,891,888 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have two buttons in my page login and register,
If i click login am showing a login popup(user id and password) ,
if this pop up stable for 5 minutes , i want redirect that to expired.aspx page, how to do this

this is my code


ASP.NET
<form id="form1"  runat="server">
<input type="hidden" name="ctl00$TxbWater1_ClientState" id="TxbWater1_ClientState" />
<div >
<div id="light" class="white_content">
<table cellpadding="0" cellspacing="0" border="0" style="background-color: #FFFFFF; font-family: Verdana, Geneva, Tahoma, sans-serif;"
width="100%">
<tr>
<td height="16px">
<a href="java<!-- no -->script:void(0)" id="pop_up_pretrazivanje:closeButton" >
<img src="Images/delete.png" style="border-style: none; border-color: inherit; border-width: 0px; height: 20px; width: 20px;"
align="right" alt="Close" /></a>
</td>
</tr>
<tr>
<td style="padding-removed 16px; padding-removed 16px; padding-removed 16px">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color: #fff"
width="100%">
<tr>
<td align="center" colspan="2" class="headertext">
<h1 class="LoginHead" align="center">LOGIN</h1>
</td>
</tr>
<tr>
<td> 
</td>
</tr>
<tr>
<td align="center">
<table>
<tr>
<td align="right" class="bot_text">Username:
</td>
<td>
<%--<input type="text"  runat="server" id="txtSearchTerm" placeholder="Username" value="txtName" />--%>
<asp:TextBox ID="txtName" runat="server" placeholder="Username"></asp:TextBox>
</td>
</tr>
<tr>
<td height="10px"></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
ErrorMessage="User ID Required" ValidationGroup="a" CssClass="content3" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="bot_text">Password:
</td>
<td>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" placeholder="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right"></td>
</tr>
<tr>
<td height="10px"></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPassword"
ErrorMessage="Password Required" ValidationGroup="a" CssClass="content3" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td align="center">
<asp:Button ID="_btnLogin" runat="server" Text="Login" CssClass="Button1" ValidationGroup="a"
Height="40px" Width="100px" />
</td>
</tr>
</table>
<table>
<tr>
<td>
<a href="ForgotPassword.aspx" class="style4" style="font-family: Verdana">Forgot password?</a> 
|  <a href="Registration.aspx" class="style4" style="font-family: verdana">Register</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10px"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="fade" class="black_overlay">
</div>
</div>
<asp:Panel ID="Panel1" runat="server">
<pre style="margin-removed 10px"><a href="java<!-- no -->script:void(0)" >Login</a>|<a class="anchor"
href="Registration.aspx" style="font-family: verdana; font-size: small; color: #0000FF;">Register</a>


</form>


Javascript

<script type="text/javascript">
window.onkeyup = function (event) {
if (event.keyCode == 27) {
window.close();
}
}
</script>
<script type="text/javascript">
document.onkeydown = checkKeycode2
function checkKeycode2(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if (keycode == 27) {
var obj;
obj = document.getElementById('pop_up_pretrazivanje:closeButton');
if (obj != null) {
document.getElementById('pop_up_pretrazivanje:closeButton').click();
}
}
}
</script>
Posted
Updated 20-Jan-16 20:28pm
v2
Comments
Sergey Alexandrovich Kryukov 21-Jan-16 2:25am    
What is "pop window"? What this expiration should do?
—SA
Member 11382784 21-Jan-16 2:31am    
sorry it is pop up window, if user is idle for 5 minutes after clicking login button , i wants to expire his session then redireting him to expire page(aspx page)

1 solution

Just use the javascript settimeout function an pass it 5 minutes worth of milliseconds. 300000, see example z[^]

then use the method to navigate to the expired page.

Or you could name your popup window from the launching page and keep the timeout there, then you can close it and navigate in the original window.
 
Share this answer
 
Comments
F-ES Sitecore 21-Jan-16 4:40am    
Whilst I agree this would be the best approach for such a "problem", it's not quite as simple as above. Let's say I've been idle for 4 mins and 40 seconds, then I slowly start to enter my username and password....and I get taken away from the form. The timer would need to reset itself on certain events such as the keyup events on textboxes, the blur and focus events, maybe even the mouse in and mouse out events.
Thomas Nielsen - getCore 21-Jan-16 6:04am    
Yea it is :) of cause you need to have a keypress event then to clear the timeout and set a new one or store time of last keypress and let some shorter timeout verify that time was more than a plausible typerate and then clear and reset (to not get too many whilst a person is typing something) as an example, so yea the principle is the same but you are quite right in mentioning some of the details required for a good solution i totally agree, but just thought to ony outline the approach would be easily enough to get the asker Member 11382784 in the right direction

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900