node visible

4 posts, 0 answers
  1. Kjell
    Kjell avatar
    212 posts
    Member since:
    May 2011

    Posted 28 Nov 2016 Link to this post

    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
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1332 posts

    Posted 28 Nov 2016 Link to this post

    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.
  3. Kjell
    Kjell avatar
    212 posts
    Member since:
    May 2011

    Posted 02 Dec 2016 in reply to Ivan Danchev Link to this post

    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?

  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1332 posts

    Posted 06 Dec 2016 Link to this post

    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.
Back to Top