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
    System.Web.UI.HtmlTextWriter)
    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
    abargaddon, Jan 17, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. naijacoder naijacoder
    Replies:
    1
    Views:
    656
    naijacoder naijacoder
    Sep 15, 2004
  2. tanya foster
    Replies:
    3
    Views:
    3,699
    tanya foster
    May 18, 2006
  3. Chakravarthy

    TreeNode Control with 2 links for each element

    Chakravarthy, Mar 10, 2009, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    689
    Chakravarthy
    Mar 10, 2009
  4. Michel
    Replies:
    2
    Views:
    138
    Michel
    Aug 2, 2004
  5. lcplben
    Replies:
    3
    Views:
    481
    Garrett Smith
    Oct 30, 2009
Loading...

Share This Page