Kentico CMS 7.0 Tutorial ASPX

Main menu

Main menu

Previous topic Next topic Mail us feedback on this topic!  

Main menu

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Now we will add a dynamic drop-down menu to the master page. You can implement the drop-down menu using either the CMSMenu or CMSListMenu control. The example uses the first option, which is easier to understand if you are not familiar with advanced CSS styles.

 

 

InfoBox_Note

 

Note

 

If you prefer a drop-down menu based on CSS styles and UL/LI elements, you can try using the CMSListMenu later. See the Kentico CMS Controls Reference for additional details and examples.

 

 

1. Edit the MyMaster.master file in Visual Studio.

 

2. Remove the <table> element used as a static menu inside the <div class="MainMenu"> element. Instead, drag the CMSMenu control from the toolbox to this location.

 

3. Set the following properties of the CMSMenu control (you can find them in the Behavior section of the Visual Studio Properties window):

 

Property

Value

Description

Path

/%

Configures the menu to display pages starting from the root of the site structure.

Layout

Horizontal

Sets a horizontal layout for the menu.

CSSPrefix

;sub

Allows you to add prefixes before the names of the CSS classes applied to the menu. The ;sub value uses unmodified class names for the main (first) menu level and the sub prefix for the second level and all other sub-levels.

Cursor

Pointer

Specifies the type of mouse cursor displayed when a user hovers over the menu.

 

The code of the main menu section should now look like this:

 

<!-- main menu -->
<div class="MainMenu">
  <cms:CMSMenu ID="CMSMenu1" runat="server" Path="/%" Layout="Horizontal" CSSPrefix=";sub" Cursor="Pointer" />
</div>

 

4. Save the changes.

 

The master page is now prepared and you can assign it to the site's ASPX templates. Continue by creating the Home page of the website.

 

 

InfoBox_Tip

 

Kentico CMS Controls and Web Parts

 

Kentico CMS provides a set of flexible server controls in the CMS.Controls.dll library, but large amounts of the built-in functionality are only available through web parts stored in the CMSWebParts folder.

 

These web parts are standard ASCX user controls and you can use them on both portal engine templates and ASPX pages. To add a web part onto your ASPX pages, drag it from the Solution explorer and set the properties in the Properties window.