9CBS - Document Center - .net title How to implement the left and right key menu on the control placed on the ASP.NET page, the same, the LYX123 (original) keyword ASP.NET, right-click menu
Foreword: You may have developed a lot of solutions for a number of Windows interfaces. For the use of menus, it can be said to be frogged. Of course, how to implement the left and right key functions on the Windows window is not there. But how do you implement the menu in the web window? Many people say it. Implement with JavaScript or VBScript. Completely correct. It is generally written in the front desk language. There are also ways to implement in a way that is not used with scripting languages. Methods to implement with the control can refer to the article I wrote "ASP.NET-based WebMenu" operation ", it is easy to use the control.
I am talking about the problem of the old man, if the master passes, please give a point, but also don't give too much brick. text:
Implement the pop-up of the left and right keys, and select the different menus of the left and right keys, click on the menu to have different processing results, such as popping up the mode and no mode dialog, etc.
As described below: (1): Pop up the menu in the Click event of the control and DBLClick event.
Prerequisites: Control supports clicking and double-click event. (I am afraid not to support the control of the control, I am afraid there. 嘿嘿)
Add your own menu function in the Click event of the control and DBLClick event. This function is typically drawing a table on the screen. Get the role of the pop-up menu.
The original function of my painting table is as follows:
Function Showdiv (DIV, XPOS, YPOS) where DIV is the type of menu. For example, the type "substation" or "line", the contents of the two menus popped up are different. This is implemented to pop up a plurality of menus on the same control. Among them, XPOS, YPOS's role is where pop-up menu, generally coming to the offset of the mouse pointer and the right point. Outside: How to get XPOS, YPOS, can get the screen coordinates. This function is implemented by JavaScript. Suppose it is "Line", then we see the picture of the above, how can you implement the picture frame? My implementation method shows that the menu function is called in this function. This function is actually added in an array, adds items of each menu to an array, and take the value of the array in the following menustyle function. The prototype of this function is as follows: AddMenuItem (Text, URL, IMG) where text is displayed on the menu, the URL is the address of the link to where the change is changing the menu. Image is an optional item. When it is a graph, the graph is displayed on the menu. The following is this function:
function addMenuItem (text, url, img) {if (img) menuItems [menuItemNum] = new Array (text, url, img); elseif (text) menuItems [menuItemNum] = new Array (text, url); else menuItems [menuItemNum ] = new array (); menuitemnum ;} At the same time, you can also increase the style of the menu and the click and Mousemove effect of the menu, and the function is: menustyle (), no parameters. Finally, to display the menu, the menu function is: showMenu (), no parameters.
This enables the pop-up of the menu. The following is a complete instance code:
SUB GNV_Click (Byval Button, Byval Key, Byval Windowcoord, BYVAL World "{SELECT CASE button Case 1 'Left M_OcurrentCoordinate = WINDOWCOORD' represents the mouse position, other different controls are to get this value through different methods. call showdiv ( "line", m_oCurrentCoordinate.x, m_oCurrentCoordinate.y 15)} The above code implemented by vbscript accomplished function showdiv (div, XPos, YPos) redefine the javascript {// Array menuItemNum = 0; menuItems = Array ( ); menuxpos = xpos; menuypos = ypos; switch (div) {copy "menu type": // Refine height and width menuwidth = 143; // Menu width Each Chinese character width 24 menuHeight = 158; // Menu Height AddMenuItem (); Break; Case "another menu type": // is another case. Slightly default: Break;} Menustyle (); // Menu Style ShowMenu (); // Display Menu} Menustyle (); // Function Slightly, in the following selection menu and click on the menu. Function Showmenu () {Menupopup.show (MenuPos, Menuypos, Menuwidth, MenuHeight, Document.body); Return False;} (untrained)