Programmatically Created RadAjaxManager won't work properly

2 posts, 0 answers
  1. Michael
    Michael avatar
    12 posts
    Member since:
    Jan 2008

    Posted 26 Oct 2011 Link to this post

    I'm programmatically creating a RadAjaxManager object as I'm creating custom webservercontrol that wraps the Grid, ContextMenus, and a Loading Panel to do some custom operations.

    So far, I've been unable to get the RadAjaxManager to operate as it does when it's added directly to a page.  The loading indicator doesn't show up on the grid at all, and I consistently get an error when attempting to fire Rebind on the grid from an ajaxRequest:

    'ctl00_MainContent_SpreadsheetControl_ctl00_MainContent_SpreadsheetControl_MainGridPanel'. If it is being updated dynamically then it must be inside another UpdatePanel.

    The code used to create and initialize the objects is below.
    Any idea what the issue could be?

    protected void CreateControls()  //Called from CompositeControl constructor
            {
                AjaxManager = new RadAjaxManager() { ID="AjaxManager", EnableAJAX = true};
                InputManager = new RadInputManager() { EnableEmbeddedBaseStylesheet = false };
                CellContextMenu = new RadContextMenu() { ID = "CellContextMenu", OnClientLoad = "onCellContextMenuLoad" };
                HeaderContextMenu = new RadContextMenu() { ID = "HeaderContextMenu", OnClientLoad = "onCellContextMenuLoad" };
                LoadingPanel = new RadAjaxLoadingPanel() { ID = "RadAjaxLoadingPanel" };
                Grid = new RadGrid()
                {
                    ID = "MainGrid",
                    AutoGenerateColumns = false,
                    AllowMultiRowEdit = true,
                    CellSpacing = 0,
                    CellPadding = 0,
                    GridLines = GridLines.None,
                    AllowAutomaticUpdates = true,
                    AllowFilteringByColumn = true,
                    AllowSorting = true,
                    GroupingEnabled = false,
                    ShowGroupPanel = false,
                };
            }
            protected void InitializeComponent()  //called from 'CreateChildControls' override.
            {
                 
                this.Controls.Add(AjaxManager);
     
                Grid.ClientSettings.Scrolling.AllowScroll = true;
                Grid.ClientSettings.Scrolling.UseStaticHeaders = true;
     
                Grid.ClientSettings.ClientEvents.OnGridCreated = "onGridCreated";
                Grid.ClientSettings.ClientEvents.OnRowCreated = "onRowCreated";
                Grid.ClientSettings.ClientEvents.OnRowDestroying = "onRowDestroying";
                Grid.ClientSettings.ClientEvents.OnRowContextMenu = "onRowContextMenu";
                 
                 
                Grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Bottom;
                Grid.MasterTableView.EditMode = GridEditMode.InPlace;
                Grid.MasterTableView.AllowCustomSorting = true;
     
                 
                this.Controls.Add(Grid);
                this.Controls.Add(CellContextMenu);
                this.Controls.Add(HeaderContextMenu);
                this.Controls.Add(LoadingPanel);
     
     
                Grid.PreRender += OnPreRender;
                Grid.ItemDataBound += OnItemDataBound;
     
                
            }
     
    protected override void OnLoad(EventArgs e)
            {
                 
                //base.OnLoad(e);
                RadScriptManager.RegisterStartupScript((Control)this, this.GetType(), this.AjaxManager.ClientID, "identifyAjaxManager('" + AjaxManager.ClientID + "');", true);
                AjaxManager.AjaxSettings.AddAjaxSetting(Grid, Grid, LoadingPanel);
                AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, Grid);
            }
            }
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 31 Oct 2011 Link to this post

    Hi Michael,

    Try following the steps in this help article as see if it makes any difference:
    http://www.telerik.com/help/aspnet-ajax/ajax-ajax-manager-programmatic-creation.html

    Kind regards,
    Iana Tsolova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top