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

showing loading panel on initial pageload in a master-content page

3 Answers 259 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
sunil
Top achievements
Rank 1
sunil asked on 05 Feb 2012, 10:27 AM
hi telerik,

         i am using codes from  http://www.telerik.com/help/aspnet-ajax/ajax-show-loadingpanel-on-initial-pageload.html  link to show loading panel .  since i am using master-content page , i have to make little change in the code as below

In Master Page

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function pageLoad(sender, eventArgs) {
                if (!eventArgs.get_isPartialLoad()) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad");
                    if (window.contentPageLoad) {
                        window.contentPageLoad(sender, eventArgs);
                    }
                }
            } 
        </script>
    </telerik:RadCodeBlock>
    <div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
            DefaultLoadingPanelID="RadAjaxLoadingPanel1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
            Loading.........
        </telerik:RadAjaxLoadingPanel>
        <asp:Panel ID="Panel1" runat="server">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </asp:Panel>
    </div>
    </form>
</body>


In Content Page

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
 
            function contentPageLoad(sender, eventArgs) {
                alert("i am from content page");
 
                // on pageLoad doing lot of stuffs for example
                document.getElementById("<%= Label1.ClientID %>").innerHTML = "hello"
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxPanel runat="server" ID="ajaxPanel">
       <%--  all controls will be residing inside the ajax panel--%>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </telerik:RadAjaxPanel>
</asp:Content>


  
now the problem is on page load the ajaxrequest starts and the contentPageLoad() assigns value to the label, but when the ajaxrequest ends the value assigned through 
contentPageLoad() is refreshed . Please Help Me.
 

3 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 08 Feb 2012, 05:20 PM
Hi Sunil,

You could resolve the issue by replacing the contentPageLoad function with pageLoad function as it is shown below. This approach is needed because the contentPageLoad fires before the RadAjaxManager ResponseEnd event. Additionally, I have attached the project I used for testing. 
function pageLoad()
{
    alert("i am from content page");
    document.getElementById("<%= Label1.ClientID %>").innerHTML = "hello"
}

Kind regards,
Antonio Stoilkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
sunil
Top achievements
Rank 1
answered on 09 Feb 2012, 07:06 AM
hi antonio,

thanks for your reply. In your attached sample the master page pageLoad is not even firing, since it is not firing , it wont initiate the ajax request..  Also i will explain my requirement , among the two pageLoad (master page and content page) events i need the master page pageLoad should fire first because i am doing lot of calculations in the content page pageLoad which may take 2 or 3 sec :-) , so if content page pageLoad is fired first then the loading panel will be shown only after performing this calculation . Waiting for your reply.  
0
Antonio Stoilkov
Telerik team
answered on 13 Feb 2012, 06:42 PM
Hi Sunil,

I have updated the project using different approach. Calling the contentPageLoad on EndRequest event as it is shown below.
<telerik:RadAjaxManager ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
    DefaultLoadingPanelID="RadAjaxLoadingPanel1" runat="server">
    <ClientEvents OnResponseEnd="ResponseEnd" />
var contentPageParameters = null;
function pageLoad(sender, eventArgs)
{
    if (!eventArgs.get_isPartialLoad())
    {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad");
        contentPageParameters = [sender, eventArgs];
    }
}
 
function ResponseEnd()
{
    if (window.contentPageLoad)
    {
        window.contentPageLoad(contentPageParameters[0], contentPageParameters[1]);
    }
}

Greetings,
Antonio Stoilkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Ajax
Asked by
sunil
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
sunil
Top achievements
Rank 1
Share this question
or