How to check if RadAjaxManager exists on the page?

2 posts, 0 answers
  1. Simone
    Simone avatar
    34 posts
    Member since:
    Mar 2011

    Posted 10 Feb 2012 Link to this post

    I get this error because I am using a user control that is inside a page that doesn't have RadAjaxManager.
    How do I check if RadAjaxManager exists on the parent page before getting the error? Some parent pages do have
    RadAjaxManager, some others don't.

    And if it doesn't exist,  I do not want to make a request.

    Thanks in advance.


    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 69:         function refreshScreen(action) {
    Line 70: 
    Line 71:             $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest(action);
    Line 72: 
    Line 73:         }   
  2. Simone
    Simone avatar
    34 posts
    Member since:
    Mar 2011

    Posted 10 Feb 2012 Link to this post

    I think I figured it out:


            function refreshScreen(action) {
                
                <%= RadAjaxManager.GetCurrent(Page) == null? "" : "$find('" + RadAjaxManager.GetCurrent(Page).ClientID  + "').ajaxRequest(action);"  %>
                    
            }  
Back to Top