I want to redirect the user to a 'Session Timeout Error' page when the session has timed out on the page. How can we accomplish this while AJAX is enabled on the grid?
bascially how do we check if the Session objects exists when the InitializeDataSource event is triggered on an AJAX reques and then redirect the user to a different page?
Hello,
Indeed, this is a tricky one. You can not use server-side redirect since this is just an Ajax call to the server and even if you detect that the session expired Response.Redirect will have no effect (other than producing different from expected response and most probably javascript error).
I believe it is possible to hook the client-side XmlHttpResponse event and either check for a specific error message that you get on the client in the gridResponse property when session expired, or try manually setting one yourself, by calling Response.Write and then Response.End in the event handler yourself (haven't actually tried that myself, may have some caveats to it).
Finally, on the client-side, with javascript, you can use window.location.href to redirect to a page you want (e.g. login page).
Here is the documetantion for XmlHttpRequest from our CSOM client-side events documentation:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR3.5/html/WebGrid_Client_Side_Events_CSOM.html
Fired after a XmlHTTPResponse has been received on the client.
String. The name of the Grid which is firing this event.
String. The id of the row that was updated.
Object. A client side XMLHTTPResponse object with the data from the server. It is also available off the grid.XmlResponseObject property.
HTH,