•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,594 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,669 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 13981 | Replies: 2
![]() |
•
•
Join Date: Sep 2005
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
Hi
I have found the following code for Redirecting the user to loginpage on Session timeout :
///////////
Protected WithEvents body As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
Response.Write("Wait for session to timeout..")
End Sub
////////
I am trying to use the same code in C#, but I get errors in the line:
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
The errors I get are as below and all are in the same above line:
) expected
; expected
; expected
Invalid Expression Term')'
; expected
Please somebody let me know how to rectify the error.
Thanks
Sandy
I have found the following code for Redirecting the user to loginpage on Session timeout :
///////////
Protected WithEvents body As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
Response.Write("Wait for session to timeout..")
End Sub
////////
I am trying to use the same code in C#, but I get errors in the line:
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
The errors I get are as below and all are in the same above line:
) expected
; expected
; expected
Invalid Expression Term')'
; expected
Please somebody let me know how to rectify the error.
Thanks
Sandy
•
•
Join Date: Nov 2005
Location: Mountain View, CA
Posts: 47
Reputation:
Rep Power: 3
Solved Threads: 1
•
•
•
•
Originally Posted by sandy2005
Hi
I have found the following code for Redirecting the user to loginpage on Session timeout :
///////////
Protected WithEvents body As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
Response.Write("Wait for session to timeout..")
End Sub
////////
I am trying to use the same code in C#, but I get errors in the line:
body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 5000 & ");")
The errors I get are as below and all are in the same above line:
) expected
; expected
; expected
Invalid Expression Term')'
; expected
Please somebody let me know how to rectify the error.
Thanks
Sandy
Hi Sandy,
try the following code.
[HTML]
string str = "window.setTimeout(window.location.href='login.aspx'," & "(Session.Timeout * 60 * 1000) + 5000);";
body.Attributes.Add("onLoad",str )
[/HTML]
Thanks,
Kedar
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
Similar Threads
- ASP Redirect on Session Timeout (ASP.NET)
- HELP: CF 4.5 Session Timeout issue (ColdFusion)
- urgent: session timeout occurs unexpectedly(given both web.config & global.asax code) (ASP.NET)
- Session variable (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Questions about C#
- Next Thread: Form not visible


Linear Mode