Geeks With Blogs

  • azamsharp The WWDC app says that there are new videos but there is nothing under videos!!! about 528 days ago
  • azamsharp Can I post my opinion on iOS 7 Beta or is it under NDA or something? about 528 days ago
  • azamsharp iOS 7 BETA installed successfully! about 528 days ago
  • azamsharp iOS 7 BETA installed! Now restoring! I am on NET10 which uses AT&T network. Hopefully 3G will still work! Lets c.. about 528 days ago
  • azamsharp The missing of button borders in Xcode 5 makes it hard to determine the clickable area. about 528 days ago
  • azamsharp I might wait for iOS to be released before I can put it on my device! Don't want a bricked or unstable device! about 528 days ago
  • azamsharp Android has many features that no one uses, number of versions that no one upgrades to and thousands of apps that no one pays for. about 528 days ago
  • azamsharp Maybe it is just me but the new iOS 7 UI looks like Windows Phone 8 UI! #maybeIamCrazy about 528 days ago
  • azamsharp Anyone using H20 network upgraded to iOS 7 BETA Keep me updated if you face any problems. about 529 days ago
  • azamsharp @merowing_ You already downloaded it! I cannot even load the developer's website! :( about 529 days ago

AzamSharp Some day I will know everything. I hope that day never comes.

Menu controls in ASP.NET 2.0 are pretty cool. I wanted to display the menu horizontally with Sub Menus on some of the menu item and I was able to do this in few minutes.

Check out the screen shot below to see what I am talking about:

The code is also pretty straight forward. First thing you need is a Web.sitemap file which will contain the text and the url of the links that you will display on the menu control.


<?xml version="1.0" encoding="UTF-8"?>
  <siteMapNode url="default.aspx" title="root">
    <siteMapNode url="subMenu.aspx?A=1" title="Home">      
    <siteMapNode url="subMenu.aspx?B=1" title="Students">
      <siteMapNode url="e.aspx" title="Add Student"></siteMapNode>
      <siteMapNode url="f.aspx" title="Drop Student"></siteMapNode>
      <siteMapNode url="g.aspx" title="View All Students"></siteMapNode>
      <siteMapNode url="h.aspx" title="Kick Student Butt"></siteMapNode>

Next thing you need is a source which will absorb the contents of web.sitemap file and spit it on the menu control. In the code below I am using XmlSiteMapProvider and SiteMapDataSource. IF you are interesting in using some other datasource for your menu control then I suggest you check out this article Populating Menu Control with Different Sources.

 protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)

private void CreateMenuControl()
    TabStripMenu.DataSource = GetSiteMapDataSource();
private SiteMapDataSource GetSiteMapDataSource()    {

        XmlSiteMapProvider xmlSiteMap = 
new XmlSiteMapProvider();
        myCollection = 
new System.Collections
        myCollection.Add("siteMapFile", "Web.sitemap");
        xmlSiteMap.Initialize("provider", myCollection);
        SiteMapDataSource siteMap = 
new SiteMapDataSource();
        siteMap.ShowStartingNode = 
return siteMap;

powered by IMHO 1.3

Posted on Thursday, March 2, 2006 3:39 PM | Back to top

Comments on this post: Displaying Menu Control Horizontal With SubMenus

# re: Displaying Menu Control Horizontal With SubMenus
Requesting Gravatar...
nice to hear you again Ray.
keep a good work with your blog.
Left by mp3 blog on Mar 27, 2006 4:33 AM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: | Join free