Malaika Consultants LLC

Step 6: Handling Menus Effectively in ASP.NET

by Jane Thomson 23. August 2011 18:05

After learning few user controls and ASP.NET Master Pages, let us look at how menu handling can be done with ASP.NET. It is really difficult to maintain the website menu of a large website and it also takes more time. A menu is generally stores inside a file in ASP.NET to make its handling easier. The file where the menu is stores is known as web.sitemap file and it is kept under the root directory on the website.

Apart from the menu, ASP.NET also contains three different navigation controls as well.

1.    Sitemap Path

2.    Tree Views

3.    Dynamic Menus

Sitemap is actually an XML file and it can be created like a regular xml file with few special tags. Let us first look at few rules to create the web.sitemap file.

1.    The sitemap file has to have <sitemap> tag that surrounds the file content.

2.    The tag <sitemap> can have only one child node that is <siteMapNode> which actually is for home page.

3.    However, <siteMapNode> can have more than one child nodes which represents web pages of the website.

4.    Each of the <siteMapNode> has at least two basic attributes of page URL and page Title.

5.    A valid web.sitemap file cannot contain a duplicate URL and URL attribute can be left empty as well.

It is important to note again that a sitemap file must be placed under the root folder and the URL attributes must be assigned with the relative path of root folder.

Here is an example of a sitemap file.

<?xml version="1.0" encoding="ISO-8859-1" ?>
  <siteMapNode title="Home" url="/aspnet/providern_home.aspx">
    <siteMapNode title="Article Writing" url="/aspnet/ providern_article_writing.aspx">
      <siteMapNode title="SEO" url="/aspnet/providern_SEO.aspx"/>
      <siteMapNode title="Link Building" url="/aspnet/providern_link_building.aspx"/>

It is also possible to use more than one sitemap files in order to portray the navigation structure of the website. For an example, a sitemap file in a root folder can be linked to a child sitemap file by referencing child sitemap file in siteMapNode element of the file.



::: | © Malaika Consultants LLC | :::

Malaika Consultants LLC

Malaika Consultants LLC is a custom software development consulting firm located in Cary (Raleigh Durham Research Triangle AKA RTP area ) North Carolina. We offer our expert consulting services in the Microsoft .NET and related technologies. Our mission is to partner with you and ensure the success of your project. We have a team in the USA that will help you with your Information Technology needs and we strive to be truly "Your Information Technology Angels"

We are offering 1 hour of free consulting -- ASP.NET, SQL Server, IIS, anything. Contact us to get your free consulting

Recent Comments