How set node visible to false in PageLoad, i get error System.ArgumentOutOfRangeException....
ProtectedSubPage_Load(sender AsObject, e AsEventArgs) HandlesMe.Load
RadNavigation1.Nodes(4).Visible = False
EndSub
3 Answers, 1 is accepted
0
Ivan Danchev
Telerik team
answered on 28 Nov 2016, 11:52 AM
Hello Kjell,
This exception indicates the Navigation node collection does not contain a node on index 4. Either you are trying to access a node before the Navigation has been populated, in which case you could use the control's DataBound event as it fires after the Navigation is populated, or the Navigation has only four or less root nodes, which means RadNavigation1.Nodes will contain nodes up to index 3 and the same exception will be thrown if you try to access a node at index 4 or bigger.
Regards,
Ivan Danchev
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
I use NodeDataBound , but the problem is that the event is fires after the Navigation is populated.
The problem is that the pages I hide in NodeDataBound flash on / appears in the menu when it is loaded. Not so neat ...
I have pages (NodeId) from 1 to 110....
So I do not understand why this does not work?
ProtectedSubPage_Load(sender AsObject, e AsEventArgs) HandlesMe.Load
RadNavigation1.Nodes(4).Visible = False
EndSub
Tips on how I can hide the first 4 nodes, before they are loaded into the RadNavigation?
0
Ivan Danchev
Telerik team
answered on 06 Dec 2016, 03:38 PM
Hello Kjell,
You cannot access the NavigationNode object and its properties (Visible in this case) before it is created, so
so accessing a node at an index that does not yet exist in an empty collection (RadNavigation1.Nodes(4).Visible) will throw ArgumentOutOfRangeException. You need to access the node when it is loaded so you can either use the Navigation's OnDataBound event, which fires once after all the nodes are loaded, or the NodeDataBound event which fires for each node when it is loaded.
Regards,
Ivan Danchev
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.