Set RadAjaxLoadingPanel in master page to control update panel in content page

2 posts, 0 answers
  1. TravelMan
    TravelMan avatar
    4 posts
    Member since:
    Feb 2009

    Posted 23 Feb 2010 Link to this post

    Based on the sample code in telerik demo site, I am able put a RadAjaxLoadingPanel in content page for the update panel. It is working fine and loading image is in the center of screen. Since there have a lot of content pages have similar case, I would like to move RadAjaxLoadingPanel to Master page. Also, the javascript for updatePanel would be moved to master page too. That is meaning, I only have one code base in Master page and apply AjaxLoadingPanel for all content page with UpdatePanel.

    Does anyone have idea how to implement this? If it can do, will this still working for content page without update panel?

    Here are code I am using in content page.

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"   
        IsSticky="true" BackgroundPosition="Center" 
            Transparency="0" Height="60px" 
            Width="70px" Skin="Vista">  
        <script language="javascript" type="text/javascript">  
               function centerUpdatePanel()  
                    centerElementOnScreen(document.getElementById('<% = RadAjaxLoadingPanel1.ClientID %>'));  
                function centerElementOnScreen(element)  
                    var scrollTop = document.body.scrollTop;  
                    var scrollLeft = document.body.scrollLeft;  
                    var viewPortHeight = document.body.clientHeight;  
                    var viewPortWidth = document.body.clientWidth;  
                    if (document.compatMode == "CSS1Compat")  
                        viewPortHeight = document.documentElement.clientHeight;  
                        viewPortWidth = document.documentElement.clientWidth;  
                        scrollTop = document.documentElement.scrollTop;  
                        scrollLeft = document.documentElement.scrollLeft;  
                    var topOffset = Math.ceil(viewPortHeight / 2 - element.offsetHeight / 2);  
                    var leftOffset = Math.ceil(viewPortWidth / 2 - element.offsetWidth / 2);  
                    var top = scrollTop + topOffset - 40;  
                    var left = scrollLeft + leftOffset - 70;  
           = "absolute";  
           = top + "px";  
           = left + "px";  
            var loadingPanel = "";  
            var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();  
            var postBackElement = "";  
            function initializeRequest(sender, eventArgs)  
                loadingPanel = $find('<% = RadAjaxLoadingPanel1.ClientID %>');  
                postBackElement = eventArgs.get_postBackElement().id;  
            function endRequest(sender, eventArgs)  
                loadingPanel = $find('<% = RadAjaxLoadingPanel1.ClientID %>');  
       <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">  
  2. Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 25 Feb 2010 Link to this post

    Hello Lei,

    I would suggest you to use RadAjaxManager to ajaxify the page content instead of ASP:UpdatePanel. For that purpose you need to add a RadAjaxManager control to the master page and set its DefaultLoadingPanelID to the ID of the RadAjaxLoadingPanel situated on the master page. Then you only need to handle the manager OnRequestStart client-side vent and call there the centerElementOnScreen() method.
    In the content pages you can use RadAjaxManagerProxy to set up the desired ajax settings.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top