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