This is a migrated thread and some comments may be shown as answers.

node visible

3 Answers 18 Views
Navigation
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 28 Nov 2016, 10:03 AM

How set node visible to false in PageLoad, i get error System.ArgumentOutOfRangeException....

 

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    RadNavigation1.Nodes(4).Visible = False
End Sub

3 Answers, 1 is accepted

Sort by
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.
0
Kjell
Top achievements
Rank 1
answered on 02 Dec 2016, 01:08 PM

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?

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
 
    RadNavigation1.Nodes(4).Visible = False
 
End Sub

 

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.
Tags
Navigation
Asked by
Kjell
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or