Posts

Showing posts with the label menu

Creating a simple Context Menu on a databound ASP.NET treeview

Recently, I was in need of a right-click context menu for the ASP.NET treeview control.  I know there are many third party & open source treeview controls that have this functionality built-in, but my situation demanded that I build my own.  After much Googling, I found that most of the posted code for creating your own is complicated at best.  So, having the MS AjaxControlToolkit already in heavy use on the project, I decided to utilize it.  Here's what I came up with: I first created a menu in an asp:Panel & added a popupControlExtender from the MS AJAX Control Toolkit: New Folder Upload File Delete Folder Adjust Permissions I then added the following attribute to the asp:TreeView tag: oncontextmenu="ShowTreeviewContextMenu(this, event); Finally, I created a javascript method to handle the treeview event & display the popup in the proper place: function ShowTreeviewContextMenu(sender, menuEvent) { var selectedNode = event....