GetCurrent always returns null

11 posts, 0 answers
  1. Joshua Gates
    Joshua Gates avatar
    72 posts
    Member since:
    Feb 2007

    Posted 21 Nov 2007 Link to this post

        I have apage with an RadAjaxManager on it.. in my web user control I attempt to get set the RadAjaxManager variable using the RadAjaxManager.GetCurrent so that i can initiate an ajax postback with javascript when a radwindow closes...

    ?
  2. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 21 Nov 2007 Link to this post

    Joshua,

      I too have had issues with the GetCurrent.  I just stuck the following code in a helper class I have.  Here is what I came up with to help:

            public static RadAjaxManager GetCurrentAjaxManager(Page page)  
            {  
                if (page == null)  
                    throw new ArgumentNullException("page is null");  
     
                if (page.Master != null)  
                    return FindControl<RadAjaxManager>(page.Master.Controls);  
                else 
                    return FindControl<RadAjaxManager>(page.Controls);  
            }  
     
            public static T FindControl<T>(ControlCollection Controls) where T : class 
            {  
                T found = default(T);  
     
                if (Controls != null && Controls.Count > 0)  
                {  
                    for (int i = 0; i < Controls.Count; i++)  
                    {  
                        if (found != nullbreak;  
     
                        found = Controls[i] as T;  
     
                        if (found != null)  
                        {  
                            break;  
                        }  
     
                        else 
     
                            found = FindControl<T>(Controls[i].Controls);  
                    }  
                }  
     
                return found;  
            } 

    Hopefully it can help you with your problem...

    Jason
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matthew
    Matthew avatar
    14 posts
    Member since:
    Sep 2007

    Posted 30 Mar 2008 Link to this post

    This doesn't work either. 

    Create a master page.  Put a rad ajax manager on it. Create a content page.  This code, as referenced in all of Telerik's examples, 

    Telerik.Web.UI.

    RadAjaxManager.GetCurrent(this)

    returns null every single time.  wtf? 

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 31 Mar 2008 Link to this post

    Hi Matthew,

    Please refer to the following online example, which elaborates on this matter and to this forum post.

    Regards,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Matthew
    Matthew avatar
    14 posts
    Member since:
    Sep 2007

    Posted 31 Mar 2008 Link to this post

    "Hi Matthew,

    Please refer to the following online example, which elaborates on this matter and to this forum post.

    Regards,
    Maria Ilieva
    the Telerik team "

    Yes, that example does NOT work.  The declarative code works fine in the HTML.  However, the code-behind "RadAjaxManager.GetCurrent(this).Alert("1");" doesn't!  This is why people are posting examples of code such as this:

    "I too have had issues with the GetCurrent.  I just stuck the following code in a helper class I have.  Here is what I came up with to help: "
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 31 Mar 2008 Link to this post

    Hi Matthew,

    I have attached small example to illustrate you how to use GetCurrent().You can use the method in any page stage except Init.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Bent
    Bent avatar
    38 posts
    Member since:
    Sep 2008

    Posted 16 Dec 2008 Link to this post

    Hi there

    I don't know if everyone solved their problems, but I had the same issue when I realised that it's the order of the controls that makes the difference!

    I had placed the RadAjaxManager BEFORE the RadScriptManager, which for (possibly obvoius reasons) didn't work.
    When I switched the controls, everyone was happy...

    This is a somehow missed point in the documentation (or perhaps I'm just not thorough enough ;) )
  9. gunther
    gunther avatar
    95 posts
    Member since:
    Mar 2009

    Posted 13 Nov 2009 Link to this post

    "I had placed the RadAjaxManager BEFORE the RadScriptManager, which for (possibly obvoius reasons) didn't work.
    When I switched the controls, everyone was happy..."

    just posting to say that kenneth's solution worked perfectly for me.  swapped the blocks so the scriptmanager came before the ajaxmanager in the markup and everyone was indeed happy.
  10. Chris
    Chris avatar
    24 posts
    Member since:
    Jun 2010

    Posted 20 Jul 2010 Link to this post

    Thanks Kenneth, this was getting me frustrated. I'm so glad I stumbled on your solution.
  11. jaime
    jaime avatar
    1 posts
    Member since:
    Oct 2012

    Posted 02 Dec 2012 Link to this post

    is correct your suggest. Thanx gunther
  12. Aaron
    Aaron avatar
    1 posts
    Member since:
    Sep 2012

    Posted 08 May 2013 Link to this post

    I just want to say thanks to Bent (maybe previously Kenneth?).  I have spent countless days working on this, and it to find the solution buried in a thread that had nothing to do with my original issue.  If this isn't in the documentation it should be. And for good measure, if it is somewhere in the documentation, it really needs to also be in big bold font on the "RadAjax and MasterPage How To" article.  This was causing ALL of my RadAjaxMangerProxy controls to do Nothing, but my RadAjaxPanels worked fine (just not my ideal solution because of page structure). It wasn't until i tried to dynamically 'Ajaxify' in code behind that I got the null issue.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017