Click here to Skip to main content
Licence 
First Posted 25 Oct 2006
Views 94,648
Downloads 631
Bookmarked 191 times

MenuPilot 1.0 (Open-Source Context Menu for ASP.NET 2.0)

By | 23 Dec 2006 | Article
Fine DHTML context menu with layout of Action Lists/Smart Tags known from Visual Studio .NET 2005
Prize winner in Competition "ASP.NET Sep 2006"

Introduction

Use case #1: GridView action items

This control allows you to replace this table:

with a much more simple one:

Use case #2: Image actions

MenuPilot supports task menus for images as well. You can replace this UI:

with a more compact one:

This is especially useful if you have a page full of images and there is no space for action links.

MenuPilot Features

  • Customizable hint icon
  • Customizable colors
  • Supports data binding
  • Supports menu item separators
  • Full Visual Studio .NET 2005 design-time support
  • Compiled for ASP.NET 2.0
  • Available for three inline ASP.NET controls: HyperLink, Label and Image
  • Menu items support title and target link attributes
  • Menu items can execute JavaScript or go to a URL
  • Includes fix for Internet Explorer z-index bug
  • Includes fix for Internet Explorer windowed controls z-index bug

How it works

There is nothing complicated about the concept:

  • There are two hidden elements drawn for a MenuPilot control: the "hint icon" and the "task menu".
  • The "hint icon" appears when a user hovers over the control with a mouse (onmouseover event).
  • The "task menu" appears when a user clicks on the hint icon.
  • Both the hint icon and the task menu disappear when the user moves the mouse out of the menu.

What's required to make it work

However, there are a lot of tasks that need to be done in order to make it work nicely:

  1. It is necessary to wait some time before the hint icon is activated after the onmouseover event. It is also necessary to wait some before it is deactivated after the onmouseout event:
    function __menuPilot_activateLabel(o)
    {
      if (__menuPilot_activeId != o.id)
        __menuPilot_clearNow();
    
      if (__menuPilot_t != null)
        clearTimeout(__menuPilot_t);
    
      __menuPilot_waitingFor = o.id;
      __menuPilot_t = setTimeout(__menuPilot_activateLabelLater, 100);
    }
    
    function __menuPilot_activateLabelLater() 
    {
      document.getElementById(__menuPilot_waitingFor + 'down').style.display = '';
      __menuPilot_activeId = __menuPilot_waitingFor;
    }
  2. It is necessary to deactivate the hint icon and the task menu when a user hovers over another MenuPilot control:

    All the necessary <span> elements (i.e. the main text <span>, hint icon <span> and menu <span>) call the following function on onmouseout event:

    function __menuPilot_clearAll()
    {
      if (__menuPilot_t != null)
        clearTimeout(__menuPilot_t);
      __menuPilot_t = setTimeout(__menuPilot_clearNow, 300);
    }
    
    function __menuPilot_clearNow()
    {
      var id = __menuPilot_activeId;
      if (id == null)
        return;
      __menuPilot_deactivateLabel(document.getElementById(id));
      __menuPilot_deactivateMenu(document.getElementById(id + 'menu'));
      __menuPilot_activeId = null;
      __menuPilot_isActiveMenu = false;
    }
  3. It is necessary to draw the menu over all <select> elements in Internet Explorer:

    There is a workaround available for an IE bug that draws all <select> elements always on the top (i.e. over the menu). See http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx

The controls

There are three controls available in MenuPilot:

  • MenuPilotHyperLink
  • MenuPilotLabel
  • MenuPilotImage

They are derived from standard HyperLink, Label, and Image controls so all the standard functionality is available.

[PersistChildren(false)]
[ParseChildren(true, "MenuItems")]
[DefaultProperty(null)]
[Designer(typeof(ControlDesigner))]
[ToolboxBitmap(typeof(HyperLink))]
public class MenuPilotHyperlink : HyperLink
{
//...

It only adds the customization properties:

Property Type Description Default value
AppearAfter System.Int32 Number of milliseconds to wait before the hint icon appears. 100
DisappearAfter System.Int32 Number of milliseconds to wait before the menu disappears. 500
HintIcon System.String Path of the hint icon. "action.gif"
HintIconHeight System.Int32 Hint icon height in pixels. 11
HintIconWidth System.Int32 Hint icon width in pixels. 11
MenuActionColor System.Drawing.Color Color of the task menu items (hyperlinks). #2859AB
MenuBackColor System.Drawing.Color Color of the task menu background. #F0EEE1
MenuBorderColor System.Drawing.Color Color of the task menu border #ACA899
MenuFontSize System.String Task menu font size (CSS syntax). 8pt
MenuItems
MenuPilot.Web.Ui.<br />MenuItemCollection
Collection of menu items. null
MenuTitle System.String Title of the task menu. "Tasks"
MenuTitleBackColor System.Drawing.Color Color of the task menu title background. #C1D2EE
Value System.String Bindable string property that is used for passing some value to menu item hyperlinks. null

Acknowledgements

  • Joe King Sample for using a DIV IFRAME shim to cover over SELECT Boxes and other windowed controls in IE

Resources

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Dan Letecky



Czech Republic Czech Republic

Member

My open-source ASP.NET 2.0 controls:
 
DayPilot - Outlook-like calendar/scheduling control
DayPilot MonthPicker - Light-weight month picker
MenuPilot - Hover context menu

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionSub menu Pinmemberkeyur soni1:23 26 Jul '11  
GeneralMy vote of 5 PinmemberRhuros0:02 24 May '11  
GeneralIssue PinmemberShawn Lawsure9:31 21 Apr '11  
GeneralNice one! PinmemberSandeep Mewara6:40 30 Mar '10  
NewsSource code available online PinmemberGilad Khen16:47 30 May '09  
QuestionTreeNode PinmemberLeleHalfon12:02 7 Mar '07  
GeneralRe: TreeNode Pinmemberpoteet17:52 30 Apr '07  
Generalnice ! I will translate this article to chinese ,and post on cnblogs.com and intorduce to chinese programmer Pinmemberyueue17:18 25 Jan '07  
QuestionCould you add a change history? Pinmemberroberthking3:41 26 Dec '06  
QuestionTrigger linkbuttons in datagrid? [modified] PinmemberRoVliet23:33 18 Dec '06  
AnswerRe: Trigger linkbuttons in datagrid? PinmemberRoVliet5:43 20 Dec '06  
GeneralReally nice, but i've got a problem PinmemberJosema2:43 18 Dec '06  
GeneralRe: Really nice, but i've got a problem PinmemberDan Letecky10:29 18 Dec '06  
GeneralRe: Really nice, but i've got a problem PinmemberJosema22:04 18 Dec '06  
GeneralRe: Really nice, but i've got a problem PinmemberShawn Lawsure7:41 16 Apr '11  
QuestionGreat Control! Will this work with VE??? PinmemberTomMolskow7:17 13 Dec '06  
AnswerRe: Great Control! Will this work with VE??? PinmemberDan Letecky10:29 18 Dec '06  
GeneralElegant and Exciting PinmemberVasudevan Deepak Kumar1:20 6 Dec '06  
GeneralRe: Elegant and Exciting PinmemberDan Letecky10:30 18 Dec '06  
GeneralSweet Pinmemberleppie6:03 21 Nov '06  
GeneralRe: Sweet PinmemberDan Letecky0:46 22 Nov '06  
GeneralNice work PinmemberMike Ellison5:14 10 Nov '06  
GeneralRe: Nice work PinmemberDan Letecky22:37 10 Nov '06  
GeneralRe: Nice work PinmemberMike Ellison4:44 11 Nov '06  
GeneralRe: Nice work PinmemberDan Letecky0:48 22 Nov '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 23 Dec 2006
Article Copyright 2006 by Dan Letecky
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid