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

Loading Panel not showing after first postback

6 Answers 315 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 02 Jul 2008, 10:30 PM
I have a gridview with a loading panel on a user control on a page with a master page.  The loading panel displays on the first postback (sorting, refreshing, whatever), but after that, the loading panel does not display anymore.

The page it's on is fairly complex, and I can't seem to track down what is causing this to happen.  No errors are being thrown.  The same issue appears to break my datepickers as well.

Any suggestions on what could be causing this or what to look for?

Thanks.

EDIT: I'm beginning to suspect is because the user control on which the gridview is located is dynamically added to the aspx page on page load.  Could this be?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 03 Jul 2008, 08:15 AM
Hi Angie,

If the user control is added on post-back event you need to reload this UserControl in Page_Load when needed. You can check this example for more info:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Common/LoadingUserControls/DefaultCS.aspx

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Angie
Top achievements
Rank 1
answered on 07 Jul 2008, 04:46 PM
Hi Vlad, thanks for responding. 

The control is being loaded on the page_load event of the page, including on postback.  Here is the test code:

On TestPage.aspx:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site1.Master" CodeBehind="Default.aspx.cs" Inherits="TEST._Default" %> 
<%@ Register TagPrefix="UC" Src="GRID.ascx" TagName="GRID" %> 
 
<asp:content id="pageContent" contentplaceholderid="ContentPlaceHolder1" runat="server" > 
    <asp:Panel ID="panel1" runat="server" /> 
</asp:content> 

Code behind:
public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            GRID g = (GRID)LoadControl("grid.ascx");  
            panel1.Controls.Add(g);  
        }  
    } 

Grid.ascx
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" > 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" 
        Width="75px" MinDisplayTime="1000">  
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
            style="border: 0px;" /> 
    </telerik:RadAjaxLoadingPanel> 
      
    <telerik:RadGrid  ID="RadGrid1" runat="server" 
        Skin="Vista" AllowPaging="True" AllowSorting="true" Width="97%" DataSourceID="SessionDataSource1">  
        <PagerStyle Mode="NumericPages" /> 
        <MasterTableView AutoGenerateColumns="true"  Width="100%" CommandItemDisplay="Top" PageSize="5">  
        </MasterTableView> 
     </telerik:RadGrid><br /> 
              
           
    <asp:SqlDataSource  id="SessionDataSource1" 
        runat="server" selectcommand="SELECT * FROM [sites]" 
         connectionstring="<%$ ConnectionStrings:TESTConnectionString2 %>">  
    </asp:SqlDataSource> 

So you see, the control being added to the page contains the gridview and all the operations on it.  I think the example given is more for tab containers where the control actually changes. 

Can I get the loading panel to work in this situation?  Thanks.

Edit:  Dynamically adding the control in this manner also breaks the date picker if it is on the control, specifically if it's shown/hidden, i.e. on an edit template in a grid view. 
0
Neil Sloan
Top achievements
Rank 1
answered on 08 Jul 2008, 09:03 PM
Make sure you assign the control an ID, I have had issues with dynamically created controls where I haven't assgined an ID and the AJAX.
0
Angie
Top achievements
Rank 1
answered on 08 Jul 2008, 09:14 PM

Thanks Neil.  I did try that and it didn't seems to make a difference.
 

GRID g2 = (GRID)LoadControl("grid.ascx");  
g2.ID = "g2";  
 panel1.Controls.Add(g2); 

Is this what you mean? 

Thanks!

0
Neil Sloan
Top achievements
Rank 1
answered on 09 Jul 2008, 07:32 PM

Why do you have the ajax manager in the ascx?

I have a similar setup as you.  I have a master page, with a content page.  Inside the content page is a user control, that actually contains other user controls with grids.

I have the AjaxManager on the master page, then use the AjaxManagerProxy for the content page and user controls.

I just make sure that the first items in the content place holder or the control are:

<asp:ScriptManagerProxy ID="AjaxScriptManagerProxy" runat="server"></asp:ScriptManagerProxy>
<telerik:RadAjaxManagerProxy runat="server" ID="AjaxManagerProxy" ></telerik:RadAjaxManagerProxy>


If you use this setup, you never actually need more than one loading panel, just setup the RadAjaxManager on the master page with a default loading panel.

Here is the master page code:
   

    <telerik:RadScriptManager ID="MasterScriptManager" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="MasterAjaxManager" runat="server" EnableAJAX="true" DefaultLoadingPanelID="MasterAjaxLoadingPanel"
            >
            <AjaxSettings>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadStyleSheetManager ID="MasterStyleSheetManager" runat="server">
        </telerik:RadStyleSheetManager>
        <telerik:RadAjaxLoadingPanel ID="MasterAjaxLoadingPanel" runat="server" runat="server" Height="75px"
        Width="75px" Transparency="10">
        <img alt="Loading..." src='<%= originalAttribute="src" originalPath="'<%=" RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>

You just register your grid with the local ajaxmanagerproxy.

0
Neil Sloan
Top achievements
Rank 1
answered on 09 Jul 2008, 07:38 PM
Also, you can only have one RadAjaxManager on any page, that is why you need to use the RadAjaxManager on the master, and the RadAjaxManagerProxy on the content pages / user controls.  I do not know what would happen if you had two user controls on a page, both with a RadAjaxManager on them, but from what I've read, it shouldn't work.
Tags
Ajax
Asked by
Angie
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Angie
Top achievements
Rank 1
Neil Sloan
Top achievements
Rank 1
Share this question
or