how to access the Page from a TreeNode (treeview 's element) : addinga context menu to a treeview

Discussion in 'ASP .Net Building Controls' started by abargaddon, Jan 17, 2008.

  1. abargaddon

    abargaddon Guest

    Hi all,

    I have derived the TreeNode class in order to have it templated, and
    that works well. However, in the template I put a control (a link to a
    menu) that refers to another control (the menu itself) in the page but
    outside the template.

    It does not work because the inner control (link to a menu) fails to
    find the other control, which it searches in its Page attribute. It
    looks like the Page property is null when in a template.

    The code is in VB.NET, which I like less than C# :

    Protected Overrides Sub AddAttributesToRender(ByVal writer As
    If Not (System.Web.HttpContext.Current Is Nothing) AndAlso Not
    Me.Page Is Nothing AndAlso Me.Enabled AndAlso
    Me.ContextMenuToOpen.Length > 0 Then

    That test fails because Me.Page is Nothing.

    So, how can I set the Page attribute of each TreeNode, or access the
    TreeView object from the TreeNode object ?

    Thanks in advance,
    abargaddon, Jan 17, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.