I am trying to create RadDocks dynamically and add them to static RadDockZones in Page_Load but I get the following error:
"Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request."
What can be the source of this problem?
My structure is as follows:
- I have a master page having a RadScriptManager
- I have an aspx page that inherits from this master page
- I have 3 RadDockZones inside a RadDockLayout in this aspx page with ids DZ1, DZ2 and DZ3
- In the Page_Load function of this aspx page, I am trying to create RadDocks dynamically and add them to these RadDockZones. The contents of these RadDocks are loaded from separate ascx files:
RadDock oDock1 = new RadDock(); |
oDock1.Title = "First Dock"; |
oDock1.ID = "radDock1"; |
Control oCtrl1 = LoadControl("~/Controls/Dock1Contents.ascx"); |
oDock1.Controls.Add(oCtrl1); |
RadDockZone oZone1 = DZ1; |
oZone1.Docks.Insert(0, oDock1); |
RadDock oDock2 = new RadDock(); |
oDock2.Title = "Second Dock"; |
oDock2.ID = "radDock2"; |
Control oCtrl2 = LoadControl("~/Controls/Dock2Contents.ascx"); |
oDock2.Controls.Add(oCtrl2); |
RadDockZone oZone2 = DZ2; |
oZone2.Docks.Insert(0, oDock2); |
RadDock oDock3 = new RadDock(); |
oDock3.Title = "Third Dock"; |
oDock3.ID = "radDock3"; |
Control oCtrl3 = LoadControl("~/Controls/Dock3Contents.ascx"); |
oDock3.Controls.Add(oCtrl3); |
RadDockZone oZone3 = DZ3; |
oZone3.Docks.Insert(0, oDock3); |