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

Pre-Loading RadWindows?

1 Answer 87 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 01 Sep 2011, 06:44 PM
Hi,

I have some dialog windows which pop-up. They hold an .aspx file for content. I was hoping to make the load times snappier for first load. Is this possible? I know that the window has the option of being cached after first display, which is nice, but sometimes I feel like it takes way too long to display a RadWindow because of the controls I'm having to load.

In addition, I've got two types of windows. Some of them have completely static controls -- what is being displayed is always what is going to be displayed. Others get pre-populated with data before being displayed to the user. It would be nice to be able to pre-load the page without the data, then only have to take the time for client-side scripts to execute before displaying to the user. Is this possible?

Cheers,

Sean 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 03 Sep 2011, 01:08 PM
Hello Sean,

The most common way of having the content of the RadWindow already loaded when you first show it is by using is ContentTemplate. In this way the controls you put there are part of the main page and are thus loaded with it. This will allow an instant display when the RadWindow's show() method is called, yet it will increase the overall initial page load time. For lighter dialogs with static content this is perhaps the better approach, since also accessing the controls from the main page is easier that way. Please take a look a this online demo to see how it behaves in this scenario. This is perhaps the better option for the ones with static content.

As for preloading an iframe - this is quite difficult, since if it is initially hidden (for example put in the ContentTemplate) as the browser will reload it when you show it (the RadWindow). Therefore what you can do is have the RadWindow that should be preloaded to be shown on the page when it is loaded (VisibleOnPageLoad=true) but with an offset that will place it outside of the screen, then instead of its show() method you should call its center() method (or moveTo(), depending on your needs). For example:
<telerik:RadWindow runat="server" ID="RadWindow1" NavigateUrl="Default2.aspx" Top="-10000px" Left="-10000px" VisibleOnPageLoad="true">
</telerik:RadWindow>
<asp:Button ID="Button1" Text="open the RadWindow" OnClientClick="showTheRadWindow(); return false;" runat="server" />
function showTheRadWindow()
{
    $find('RadWindow1').center();
}

Please note that this RadWindow should not be modal, or it will block the screen. If you wish you can make it modal when you need to show it via its Client-side API. You can also make other modifications - such as size, behaviors, position, etc.

As for preloading the data - you could do this in the pageLoad() event of the content page if you decide to use my method of preloading. This, however, will be always executed, even for RadWindow that the user never decides to show. An alternative is to call a function declared in the content page that will do the job once the RadWindow should be shown to the user (i.e. when you call the center() method). This should be done only once the content page is loaded, though, to prevent errors. For this purpose you can raise a flag in the OnClientPageLoad event of the RadWindow.

Best wishes,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Window
Asked by
Sean
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or