Popup menu on the treeview control

Last post 02-02-2004 11:39 AM by Amarus. 4 replies.

Sort Posts:

  • Popup menu on the treeview control

    05-07-2003, 1:14 PM
    • Member
      5 point Member
    • siliinvestor
    • Member since 12-03-2002, 7:49 PM
    • Posts 1
    Hello,

    I need to be able to have a popup menu on the Treeview control, either on a right click or left click. Not to mention, the popup menu needs to be able to identify which node was clicked.

    How can this be achieved in the Treeview control ?

    TIA.
  • Re: Popup menu on the treeview control

    05-07-2003, 4:57 PM
    • Member
      30 point Member
    • kevin_jones
    • Member since 04-01-2003, 3:59 PM
    • Posts 6
    use the oncontextmenu event
    use the hovernodeindex to know what node was right-clicked on

    I made some earlier posts on this site, if you use the search feature of this site, you will find them. Search for context menu. Search for hovernode too. You might also want to search for drag and drop and take a look at that stuff.

    The following links will help you with the context menu:
    http://www.siteexperts.com/tips/styles/ts42/page3.asp
    http://devscripts.com/visit.php?sId=1786
    http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/howto/MouseCaptureCM.asp
    http://216.239.51.100/search?q=cache:nTJ7G6UernkC:www.javascripter.net/faq/rightbu2.htm+javascript+%22context+menu%22&hl=en&ie=UTF-8
  • Re: Popup menu on the treeview control

    05-07-2003, 6:59 PM
    • Member
      15 point Member
    • arizonien@pod
    • Member since 04-09-2003, 5:03 PM
    • Albuquerque, NM
    • Posts 3
    Kevin,
    Thanks to your earlier posts, I have been able to achieve a context popup menu (I have mine appear in a fixed location out of the tree because the tree appears to have a higher z-order and can cover part of the menu).

    My problem is that once I show the menu, I want that node (I have the index) to become the selected node. I am doing the following in JavaScript:
    treeview.setAttribute("SelectedNodeIndex", contextMenuIndex); where contextMenuIndex is the correct index (from the oncontextmenu handler window.event.treeNodeIndex).

    This does not work for me. Note that if I set that property during the PageLoad codebehind, I can set the initial selected node. Do I have to force a postback after setting the property in JavaScript? and how do I do that?

    TIA.
  • Re: Popup menu on the treeview control

    05-08-2003, 4:59 PM
    • Member
      30 point Member
    • kevin_jones
    • Member since 04-01-2003, 3:59 PM
    • Posts 6
    I had similar problems with the menu appearing behind controls. I went into the HTML portion of the forms designer and manually adjusted the Z-INDEX of the menu and the controls that it was appearing behind.

    I would think that setting the selected node index should work but then again I didn't try doing that on the client. Maybe reading the behavior code in the .htc file would help you understand what is going on.

    To postback to the server using javascript, I use the submit() method of the form object. Just before calling submit(), I set the value of a hidden field to let the server know what action to take. You can add the hidden field to the form on the server with RegisterHiddenField() in your C# code and then access it on the client with theFormObject.hiddenFieldName.value.
  • Re: Popup menu on the treeview control

    02-02-2004, 11:24 AM
    • Member
      50 point Member
    • Amarus
    • Member since 10-13-2003, 2:12 PM
    • Posts 10
    Does anyone have a tutorial on how to do this? I am new to asp.net and web programming in general. Any help will be much obliged.
Page 1 of 1 (5 items)