Cutting Edge: Join the shortcut menu for the ASP.NET control (1)

xiaoxiao2021-03-05  22

Cutting Edge: Add to the shortcut menu for the ASP.NET control (1) English Original:

Add a context menu to asp.net controls

Author: Dino Esposito

translation:

Liu Rui

Source code:

CuttingEdge0502.exe

Although the shortcut menu is already very universal elements in the desktop application, because there is no good depiction based on the server-based technique like ASP.NET, the shortcut menu is not very common in the web application. To use shortcut menu, browser must highly support DHTML and enrich event mode, such as Microsoft® Internet Explorer 5.0 and higher, or Netscape 6.0, etc. However, although the object mode of various browsers is functionally large, the members each name is different, which requires the transition from one model to another model to realize the object and event.

Here, we create an ASP.NET shortcut menu for the object mode of Internet Explorer. Then I will modify it to support other browsers. The code supports ASP.NET 1.x, or it can be compiled under ASP.NET2.0 Beta1 through Outline of Thae

ContextMenu Control Shortcut Menu Controls Overview: MSDN LIABRARY contains several DHTML shortcut menu examples. It provides a method of implementing this feature. A shortcut menu is a set of tag code in any location in the page. It consists of two partial contents - interfaces and scripts (when users are related to page UI), the UI provides a list of clicks - menu items - and their respective content text, icon, command name (Command Name ), Target URL, Tooltip, and all you think it is necessary to display something. The shortcut menu interface is part of the page and belongs to one member in the page control tree. (Too many shortcut men will have a problem: ASP.NET will send more shortcuts to your browser when the user is right-click on the page of the page. Injecting a javascript, this script moves the shortcut menu to the right click position display. The shortcut menu will keep hidden properties, and only when the user is right-click on a shortcut menu on a page, the shortcut menu is displayed. Page elements receive script events and pop up a shortcut menu as a response. Script event relies on the browser, which is an onContexMenu event in Internet Explorer 5.0 and updated. In Netscape6.0 and updated versions you want to use onMouseUp events (in Internet Explorer 5.0 , you may also use the onmouseup event, but write more Several lines of code) In the script of the event, get the UI code block of the shortcut menu and move it to a click-to-click. At the same time, set the pop-up Panel's Visibility property. When the user clicks on the menu item, the page returns and triggers server-side events. For the server, click on a menu item and click on a regular button. What should I do when the user wants to cancel the shortcut menu that has been opened? In a Windows program, press the ESC key or click the pop-up shortcut menu outside the menu area. So you must implement this in the web. Please note that only the shortcut menu is in the event (displayed), the ESC button has suburbs. Because ESC can also be used for other keyboard shortcuts for other elements. I also allow the menu to hide when the user mouse is removed. You can implement the ONMOUSELEAVE event through the script. Use the pop-up menu control to assume that we have designed this pop-up menu (how do we say how to implement this shortcut control after a while, how do you add one or more shortcut menu in the ASP.NET page? First, drag one or more shortcut menu controls to the page in the works of Visual Studio® .NET. Then, add menu items for each menu and configure the tool tips, command names, and other desired contents, such as shortcuts, and links for each menu item. Command name (Command Name) is used to determine which menu item is clicked when responding click shortcut menu; a menu item set for each shortcut menu control instance it must be unique. You must join the code in the onContextMenu event in the HTML tag to pop up the shortcut menu, the code must trust a series of parameters, like the X, Y coordinate, click-to-element, and instances of the shortcut menu to use. Note: If necessary, you can use this way to fully replace the browser shortcut menu. The JavaScript code that binds to the ONCONTextMenu event is generated during runtime. The ContextMenu control will expose a collection attribute to include a collection of controls that are binding shortcut menu, and the ContextMenu control will be bonded to these controls to be bonded onContextMenu properties.

转载请注明原文地址:https://www.9cbs.com/read-39111.html

New Post(0)