C # Menu navigation

Source: Internet
Author: User

The Menu Control is a Menu used on a page. The control has two display modes: static mode and dynamic mode. The menu items in static mode are always fully expanded. In this mode, set the StaticDisplayLevels attribute to specify the display menu level, if the menu level exceeds the value specified by the StaticDisplayLevels attribute, the exceeding level is automatically set to dynamic mode display. In dynamic mode, submenu items are displayed on the parent node only when a user's mouse event is returned. The MaximumDynamicDisplayLevels attribute specifies the display level of the dynamic menu. If the menu level exceeds the value specified by this attribute, it does not display the exceeding level. The simplest use of the www.2cto.com Menu Control is to add a set of MenuItem objects using the Items attribute in the design view. The MenuItem object has a NavigateUrl attribute. If this attribute is set, click the Menu item and navigate to the specified page. You can use the Target attribute of the Menu control to specify the location where the page is opened, the MenuItem object also has a Target attribute, which can separately specify the location where the page is opened. If the NavigateUrl attribute is not set, the page is submitted to the server for processing. This example shows how to use the Menu control to implement navigation. The technical points of using the Menu control to implement navigation are as follows. The  MenuItem object indicates that a menu item can set the menu content and navigation mode through its attributes. You can use either the designer or programming to add the Menu items. The  StaticDisplayLevels attribute specifies the display level of the static menu. Step 1: Create an ASP. NET Website in VS2010 and name it "MenuSample ". (2) Add a page named "Menu. aspx" and set this page as the start page. (3) Select the Menu control design page from the toolbox, and open the Menu item editing interface in the Items properties of the window, and add two Menu Items, system operation and help, 22.3. (4) when loading the page for the first time, specify some properties of the Menu control programmatically and add sub menus for each Menu item. The Code is as follows. <% @ Page Language = "C #" AutoEventWireup = "true" %> <script runat = "server"> protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {this. menu1.Orientation = Orientation. horizontal; // set the menu to show this horizontally. menu1.StaticDisplayLevels = 1; // only the level 1 menu is displayed this. menu1.Target = "_ blank"; // specify MenuItem register = new MenuItem () in a new window; // define the sub-menu register. text = "registered user"; register. navigateUrl = "~ /Register. aspx "; this. menu1.Items [0]. childItems. add (register); // Add sub-menu MenuItem Login = new MenuItem (); Login. text = "Login"; Login. navigateUrl = "~ /Login. aspx "; this. menu1.Items [0]. childItems. add (Login); MenuItem help = new MenuItem (); // defines the sub-menu help of the second menu. text = "help"; help. navigateUrl = "~ /Help. aspx "; this. menu1.Items [1]. childItems. add (help); MenuItem About = new MenuItem (); About. text = "About"; About. navigateUrl = "~ /About. aspx "; this. menu1.Items [1]. childItems. add (About );}} </script>

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.