Home     About PeterBlum.com     Policies     Download a Licensed Product     Newsletter
Peter's Interactive Pages
ContextMenu Control

The Context Menu is a client side menu that looks like the same context menus users see when they right click in the browser. When the user clicks on a command, it runs a client side script that you supply.

Its features include:
  • Runs JavaScript that you supply, go to a URL that you specify, or postback. It can fire validation and offer a confirmation message prior to taking any of those actions.
  • Styled like a traditional context menu but you can control the styles
  • Can show and invoke a command's keyboard shortcut
  • Can show a separator line
  • Can show a hint row which is not selectable and uses a different style
  • Rights on left, right or both mouse buttons
  • Can be hooked up to any control or the page itself

Demo

Right click in this textbox to see a menu with three items. A command (which supports CTRL+K when focus is in the textbox), a separator, and a hint.

ASP.NET Syntax for this demo

<asp:TextBox ID="ContextMenuTextBox1" runat="server" />
<des:ContextMenu ID="ContextMenu1" runat="server">
  <ClickList>
    <des:ClickItem MouseButtonType="Right" ControlID="ContextMenuTextBox1" />
  </ClickList>
  <des:CommandMenuItem OnClickScript="alert('All commands run Javascript. In this case, it called the alert() function.');" 
      CommandLabel="Command 1" CommandID="1" CommandKey="CTRL+K" />
  <des:SeparatorMenuItem/>
  <des:HintMenuItem Hint="The above was a separator" />
</des:ContextMenu>