Create RadAjaxManager in codebehind

2 posts, 0 answers
  1. Eric
    Eric avatar
    24 posts
    Member since:
    Jan 2008

    Posted 14 Mar 2011 Link to this post

    Hi,

    Is it possible to create RadAjaxManager in codebehind?

    I have a master page and I am creating a RadAjaxManager in the OnInit method of the master page. Later when I try to ajaxify a control within an aspx page using the AddAjaxSettings method I created in master page I get Object reference not set to an instance of an object.

    Master Page
    protected override void OnInit(EventArgs e)
    {                       
    HtmlForm form = (HtmlForm)this.Controls[3];
    form.Controls.Add(new RadAjaxManager());
    }
     
    public void AddAjaxSetting(Control ajaxified, Control updated, RadAjaxLoadingPanel loading)
    {
    HtmlForm form = (HtmlForm)this.Controls[3];
    RadAjaxManager ajax = form.Controls[1] as RadAjaxManager;
    ajax.AjaxSettings.AddAjaxSetting(ajaxified, updated, loading);
    }


    ASPX page
    protected void Page_Load(object sender, EventArgs e)
    {           
         (this.Master as PortalMaster).AddAjaxSetting(button, panel, loading);
    }

    Edit: I get the null reference error in ajax.AjaxSettings.AddAjaxSetting(ajaxified, updated, loading); line. All variables are pointing to correct objects (ajax, button, panel, loading).

    Thank you...
  2. Eric
    Eric avatar
    24 posts
    Member since:
    Jan 2008

    Posted 15 Mar 2011 Link to this post

    Solved. I had to add a scriptmanager before adding an ajax manager.

    form.Controls.Add(new RadScriptManager());
    form.Controls.Add(new RadAjaxManager());

    Thank you...
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top