How to implement the left and right menu on a control placed on a asp.net page and manipulate it (1
Source: Internet
Author: User
Asp.net| Menu | control | page PREFACE:
You may have developed a lot of Windows interface solutions, for the use of the menu can be said to be true, of course, how to achieve the Windows window on the left and right key function is a cinch.
But how do you implement a menu in a web window?
A lot of people say. Use JavaScript or VBScript to implement it. Absolutely right. It is generally written in a scripting language at the front desk. There are also ways to implement it based on a control that is not a scripting language. Using controls to implement the method you can refer to my written "based on ASP.net webmenu data operations," the article, using the control is very easy.
I said is a cliché of the problem, if the master passing, please give correct, also hope not to give too much bricks.
Body:
Implementation of the left and right key pop-up, and select the left and right keys of different menus, click on the menu can have different processing results, such as pop-up Modal and modeless dialog box.
as follows, a description:
(1): pop-up menu in control's Click event and DblClick event.
Prerequisites: The control supports clicking and double-clicking events. (The controls that do not support clicking and double-clicking are not much, I'm afraid.) Hey
Add your own menu functions in the Click event and DblClick event of the control. This function is usually to draw a table on the screen. The function of the pop-up menu is reached.
The following is a prototype function for my drawing table:
function Showdiv (Div,xpos,ypos)
Where the div is the type of the menu. For example, the type of "substation" or "line", the two pop-up menu content is different. This enables you to have multiple menus pop up on the same control.
Among them, the role of Xpos,ypos in what place pop-up menu, generally in the mouse pointer down a little bit and the right side for the benefit.
Outside: How to get xpos,ypos, you can obtain the screen coordinates.
This function is implemented by JavaScript.
Assuming the "line", then we see the above diagram, how to achieve the frame? My implementation method is called in this function to add a menu function. This function actually adds values to the array, adds each menu item to the array, and takes the value out of the array in the Menustyle function below. The prototype of this function is as follows:
AddMenuItem (text, URL, img)
Where text is what is displayed on the menu
Among them, the URL for the click to change the menu link to where the address.
Image is an optional item. When the representation is a graphic, the picture appears on the menu.
This function is as follows:
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 also can add menu style and menu click and MouseMove Effect, function is: Menustyle (), no parameters.
Finally, to display the menu, display the menu function as: ShowMenu (), no parameters.
This will enable the pop-up menu.
The following is the complete instance code:
Sub Gnv_click (ByVal Button, ByVal Key, ByVal Windowcoord, ByVal Worldcoord)
{
Select Case button
Case 1 ' left button
Set m_ocurrentcoordinate = Windowcoord ' represents the mouse position, and other controls have different methods to get the value.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service