Home     Download a Licensed Product     Message Board     Contact Peter     About PeterBlum.com     Policies     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"></asp:TextBox>
<des:ContextMenu id="ContextMenu1" runat="server">
  <des:MenuCommandItem CommandLabel="Command 1" CommandID="1"
    OnClickScript="alert('All commands run Javascript. In this case, it called the alert() function.');">
  </des:MenuCommandItem>
  <des:MenuCommandSeparator></des:MenuCommandSeparator>
  <des:MenuHint Hint="The above was a separator"></des:MenuHint>
  <ClickList>
    <des:ClickItem MouseButtonType="Right" ControlID="ContextMenuTextBox1"></des:ClickItem>
  </ClickList>
</des:ContextMenu>