Geeks With Blogs

AzamSharp Some day I will know everything. I hope that day never comes.
Static menus should always be stored in an xml file instead of a databases. This will increase performance and will save trips to the database. Here is a nice way to access the contents of the xml file which contains the "Name" and the "Url" of the menu items. I have also used Caching so I only have to access the file when its contents are changed.

private const string MENU = "Menu"; 
private const string MENU_FILE = "Menu.xml"; 

private DataSet BuildMenu() 
		DataSet dsMenu = new DataSet(); 
		if(Cache[MENU] != null) 
			dsMenu = (DataSet) Cache[MENU];      
			Cache.Insert(MENU,dsMenu,new System.Web.Caching.CacheDependency(Server.MapPath(MENU_FILE))); 
		return dsMenu; 

Posted on Sunday, June 26, 2005 10:55 PM | Back to top

Comments on this post: Creating menus with xml file

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: