Click here to Skip to main content
Licence CPOL
First Posted 30 Mar 2010
Views 12,836
Downloads 505
Bookmarked 14 times

Custom Web Menu with Embedded Resources

By | 30 Mar 2010 | Article
This is a free custom web menu with Tigra menu (free JavaScript menu) embedded.

Introduction

This is a free custom web menu with Tigra menu (free JavaScript menu) embedded. Menu creation and binding is dynamic. Data Source for the menu can be either an XML file or dataset filled from the DB. Menu styles can be easily overridden in the application that uses this menu using CSS. The menu supports various properties for customization. This custom article also explains how to embed resources in a custom control. The Custom web menu is a typical web menu that can be used in any web application.

Using the Code

Steps Involved in Setting the Project

  1. Download the projects.
  2. Set Default.aspx as “Set as start page”.
  3. Run the project.

Description

The control generates menu to n-depth dynamically at runtime. The data source to the menu can be either a .xml file or a dataset. The source can be set using the properties MenuXMLPath or DataSource for XML or dataset respectively.

[Category("Appearance"),DefaultValue("")]
public string MenuXMLPath
{ 
    get{return xmlDataSource;} 
    set{xmlDataSource = value;} 
} 

/// <summary>
/// DataSet from the XML menu as DataSource. 
/// </summary>

[Bindable(true),Category("Appearance"),DefaultValue("")]
public DataSet DataSource 
{
 get{return dsMenu;}
 set{dsMenu = value;} 
}

This menu use the Tigra Menu JavaScript for dynamic menu creation and binding. The menu can extend to any depth. The datasource (XML file or DB table) to the control should be of the below schema:

  • Column 1: menuid (unique ID of menu item)
  • Column 2: name (name of the menu item)
  • Column 3: root (parent of the menu item. If it is the starting/root item, then the root value will be "", else it will be the value of the parent menuid).
  • Column 4: url (URL for the menu item)

To get the DLL, please run the project “CustomWebMenu".

Embedded Resource

Set the Build Action for the resource file as "Embedded Resource" from File->Properties->Build action.

Include the below code snippet in the AssemblyInfo.cs file:

[assembly: WebResource("CustomWebMenu.Resources.CustomWebMenu.js", 
    "application/x-javascript")]

[assembly: WebResource("CustomWebMenu.Resources.Images.OneStep.gif", "image/gif")]

Points of Interest

There may be many menus available on the web. This differs from all of them in the way the resources to the Menu like JavaScript files, images, etc. are embedded with the CustomWebMenu.dll. You need not carry those resources to the projects where you are going to use the menu. You just need to refer the CustomWebMenu.dll.

Conclusion

Use the source code. Blend it with various new ideas. Feedbacks, suggestion and corrections are welcome. Enjoy coding.

The above code embeds the resource to the assembly. This prevents carrying these files to the project where the DLL is referenced.

History

  • 30th March, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

R@je$h

Software Developer

India India

Member

A C# lover....

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWeb Menu Pinmemberstixoffire18:45 5 Apr '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 30 Mar 2010
Article Copyright 2010 by R@je$h
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid