Pre-Loading RadWindows?

2 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 01 Sep 2011 Link to this post


    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?


  2. Marin Bratanov
    Marin Bratanov avatar
    5361 posts

    Posted 03 Sep 2011 Link to this post

    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">
    <asp:Button ID="Button1" Text="open the RadWindow" OnClientClick="showTheRadWindow(); return false;" runat="server" />
    function showTheRadWindow()

    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,
    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 >>

Back to Top