Ajaxified control still does postback when updated the first time

2 posts, 0 answers
  1. JP
    JP avatar
    122 posts
    Member since:
    Aug 2011

    Posted 11 Jan 2013 Link to this post


    I have this scenario:
    Two controls (say controlA and controlB), both contain some RadButtons. If a click occurs in controlA, it should update controlB and vice versa. But only case 1 works, case 2 doesn't work correctly.

    This is my code:
    protected override void OnPreRender(EventArgs e)
             RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
             manager.AjaxSettings.AddAjaxSetting(controlA, controlB, loadingPanel);
             manager.AjaxSettings.AddAjaxSetting(controlB, controlA, loadingPanel);

    The second case only works after one click, e.g. the second, third, ... click works correctly and the loading panel will be displayed.
    Both controls don't have any conditional controls, all buttons are added in CreateChildControl. EnsureChildControls is called in OnLoad of both controls.

    Which of the controls might be erroneous in this case? The control which does the trigger or the control which is updated?
  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 15 Jan 2013 Link to this post

    Hello Jan,

    In case you are using WebParts please ensure that you create the RadAjaxManager and add it to the Controls collection of the web part as follows:
    private RadAjaxManager _ajaxManager;
    protected override void OnInit(EventArgs e)
    protected void SetUpAjaxManagerOnPage()
        RadAjaxManager currentAjaxManager = RadAjaxManager.GetCurrent(Page);
        if (currentAjaxManager == null)
            Page.Form.Controls.AddAt(0, AjaxManager);
            Page.Items.Add(typeof(RadAjaxManager), AjaxManager);
    protected virtual RadAjaxManager AjaxManager
            if (_ajaxManager == null)
                _ajaxManager = RadAjaxManager.GetCurrent(Page);
                if (_ajaxManager == null)
                    _ajaxManager = new RadAjaxManager() { ID = "RadAjaxManager1" };
            return _ajaxManager;

    Also please try to place the RadAjaxSettings in the OnLoad event instead of OnPreRender and verify if this helps.

    Kind regards,
    Maria Ilieva
    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