This is a migrated thread and some comments may be shown as answers.

RadAjaxManager.GetCurrent() returns null for Nested master pages and a content page

2 Answers 252 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Abhay Jain
Top achievements
Rank 1
Abhay Jain asked on 26 Oct 2009, 11:17 AM
Hello,

I have a content page that in turn has 'nested' master pages. Please see the following:

MasterPage1
-- MasterPage2
   -- MasterPage3
       -- ContentPage

I have put RadAjaxManager (RadAjaxManagerOnMasterPage1) on MasterPage1 and a RadAjaxManagerProxy on ContentPage.

MasterPage1 has a label (LabelOnMasterPage1) that I need to update when user clicks a button (ButtonOnContentPage) lying on ContentPage.

Now, on ContentPage, I have the following code.

            MasterPage1 masterPage1
                = (MasterPage1)this.Master.Master.Master;

            RadAjaxManager radAjaxManagerOnMasterPage1
                = (RadAjaxManager)masterPage1.FindControl("RadAjaxManagerOnMasterPage1");

            if (radAjaxManagerOnMasterPage1 != null)
            {
                radAjaxManagerOnMasterPage1 .AjaxSettings.Clear();
                radAjaxManagerOnMasterPage1 .AjaxSettings.AddAjaxSetting(ButtonOnContentPage, masterPage1.GetLabelOnMasterPage1);
            }

NOTE: There is a property in MasterPage1 (GetLabelOnMasterPage1) that returns reference to LabelOnMasterPage1.

When I execute the above code, NullReferenceException is raised when AddAjaxSetting is called. Upon analysis, I found that RadAjaxManager.GetCurrent(ButtonOnContentPage.Page) returns NULL.

NOTE: GetCurrent() is eventually called in AddAjaxSetting (as per the disassembler code).

I tried writing this code both at Page_Load and OnPreRender but it worked nowhere.

Kindly tell me what is it that I am missing?

~Abhay

2 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 27 Oct 2009, 08:19 AM
Hello Abhay,

I have prepared a simple example illustrating the desired functionality. Try it out and let us know if you encounter any problems with it.

All the best,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Abhay Jain
Top achievements
Rank 1
answered on 28 Oct 2009, 05:20 AM
Thanks a ton Pavel. Your solution indeed helped me resolve the problem.

Your code was absolutely similar to what I had required except the order of RadScriptManager and RadAjaxManager on Master Page 1. In my case, I had placed RadAjaxManager before RadScriptManager. I don't know why this causes problem but the moment I changed the order the other way, GetCurrent() stopped returning null.

I completely adore Telerik Support :)
Tags
Ajax
Asked by
Abhay Jain
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Abhay Jain
Top achievements
Rank 1
Share this question
or