How to find a panel and add control to it from it's code behind

cekirge

New Member
In a master page I got a panel which I want to add controls to it from the master page's code behind as follow:\[code\]var cphRegionName = this.Page.FindControl("pnlLeft") as Panel;cphRegionName.Controls.Add(uc);\[/code\]but I get this error: \[quote\] Object reference not set to an instance of an object at cphRegionName.Controls.Add(uc);\[/quote\]I have tried all possible other ways, but get the same error.The reason I user FindControl to access the PANEL is the panel's name is dynamic ("pnlLeft"), reading from Database.
 
Back
Top