Last post Mar 02, 2012 09:41 AM by Dave Sussman
Mar 01, 2012 11:20 AM|rpk2006|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 02:49 PM|Trouble88|LINK
Menu MasterMenu = (Menu)Page.Master.FindControl("NavigationMenu")
Mar 02, 2012 06:25 AM|Bimalvv|LINK
Can you share the class that you are using?
Mar 02, 2012 09:41 AM|Dave Sussman|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.