Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 02, 2012 08:41 AM by Dave Sussman
Mar 01, 2012 10:20 AM|LINK
When I use this code to access a Master Page Menu Item, it works well but it fails when I try to run from a class.
Menu masterMenu = Master.FindControl("NavigationMenu") as Menu;
It gives error: Object Reference not set to an instance of an object.
Mar 01, 2012 01:49 PM|LINK
Menu MasterMenu = (Menu)Page.Master.FindControl("NavigationMenu")
Mar 02, 2012 05:25 AM|LINK
Can you share the class that you are using?
Mar 02, 2012 08:41 AM|LINK
The class doesn't have a property called Master, so that's the object that is null. You can't directly access the page or master from within a class.
What is it you're trying to do in that class? There will be ways to do what you want, but we need to know what you are trying to do.