This is a migrated thread and some comments may be shown as answers.

Custom Response.Write on Session Timeout

3 Answers 119 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jon A.
Top achievements
Rank 1
Jon A. asked on 10 Apr 2009, 01:18 PM
Hi,

My web app uses several radWindows that return a parameter to the parent window via a callback JS function.  These work fine, but I'd like to improve the current behavior with error trapping code that can close the form before the entire ASPX page is sent to the browser.

In the ASPX pages displayed by the radWindow, I'd like to start trapping for session time-out and other conditions within the page_load event.  To optimize performace, I'd like to use Response.Write (or Response.WriteFile) to send a custom response (simple HTML form + JS) to the browser that gracefully closes the window, bypassing the load of ASPX page content.  This approach will be much faster than injecting JS into the ASPX page via RegisterStartupScript (or similar method) that invovles the normal ASPX page lifecycle.
But in order to write a custom response to the browser, I need to ensure the response page includes the necessary Telerik JS libraries that let me (a) close the radWindow and (b) return a value to the parent page.  

Can you tell me how to do this?  Are there a set of core Telerik JS libraries that I need to include?  Ideally, I can continue using JS functions such as GetRadWindow() in order to close the form, such as:
var currentWindow = GetRadWindow();
currentWindow.argument = arg;
currentWindow.close();

Thanks.

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 10 Apr 2009, 01:53 PM
Hello Jon,

You do not need to import any libraries into your response. All you need to do is make sure the GetRadWindow function is sent over to the client

function GetRadWindow() 
  var oWindow = null
  if (window.radWindow) 
     oWindow = window.radWindow; 
  else if (window.frameElement.radWindow) 
     oWindow = window.frameElement.radWindow; 
  return oWindow; 
}   

Sincerely yours,
Georgi Tunev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Jon A.
Top achievements
Rank 1
answered on 10 Apr 2009, 05:38 PM
Sorry, GetRadWindow was clearly the wrong example of JS loaded by a JS library.

For your example code to work, don't you need to load a Telerik libarary that dyanamically adds the 'radWindow' property to the 'window' object?

I will go ahead and try loading a simple HTML into a radWindow to test your suggestion.

Thanks.
0
Tervel
Telerik team
answered on 13 Apr 2009, 08:08 AM
Hi Jon A.,

The window.radWindow variable has been set to the document inside the RadWindow by the RadWindow itself.
The RadWindow alraedy has all its scripts because it resides on a different page (e.g the parent page) - while you are dealing with a child page (e.g. the page loaded inside RadWindow). The child page needs nothing else to access the RadWindow object other than the couple of lines of javascript already provided.

Best wishes,
Tervel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Jon A.
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Jon A.
Top achievements
Rank 1
Tervel
Telerik team
Share this question
or