<p>Database? Page variables? Enum?</p>

<p>I'm looking for opinions here. </p>

[{'answer_id': 54124, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 0, 'selected': False, 'text': "<p>IF the menu is dynamic <em>per-user</em> then you'll have to hit the database for each user.  From then on I would probably store it in session to avoid future round-trips to the database.</p>\n\n<p>If it's dynamic, but the entire site sees the same items, then put it in the database and cache the results</p>\n"}, {'answer_id': 54127, 'author': 'NakedBrunch', 'author_id': 3742, 'author_profile': 'https://Stackoverflow.com/users/3742', 'pm_score': 0, 'selected': False, 'text': '<p>Binding to a Sitemap is certainly the easiest.  </p>\n'}, {'answer_id': 54128, 'author': 'Guy Starbuck', 'author_id': 2194, 'author_profile': 'https://Stackoverflow.com/users/2194', 'pm_score': 2, 'selected': False, 'text': '<p>That\'s an interesting question, there are lots of ways to approach it.</p>\n\n<p>You could load the menu structure from XML, that\'s the way the built-in ASP.NET navigation controls/"sitemap" setup works.  This is probably a good choice overall, and there is reasonably good tooling for it in Visual Studio.</p>\n\n<p>If it\'s a dynamic menu that needs to change a lot, getting the items from a database could be a good idea, but you would definitely want to cache them, so the DB doesn\'t get hit on every page render.</p>\n'}, {'answer_id': 54132, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 3, 'selected': True, 'text': '<p>The ASP.NET Sitemap feature is built for that and works well in a lot of cases. If you get in a spot where you want your <a href="http://weblogs.asp.net/jgalloway/archive/2008/01/26/asp-net-menu-and-sitemap-security-trimming-plus-a-trick-for-when-your-menu-and-security-don-t-match-up.aspx" rel="nofollow noreferrer">Menu to look different from your Sitemap, here are some workarounds</a>.</p>\n\n<p>If you have a dynamic site structure, you can <a href="http://msdn.microsoft.com/en-us/library/aa479320.aspx#custsit_topic4" rel="nofollow noreferrer">create a custom sitemap provider</a>. You might get to the point where it\'s more trouble than it\'s worth, but in general populating your menu from your sitemap gives you some nice features like security trimming, in which the menu options are appropriate for the logged-in user.</p>\n'}, {'answer_id': 54153, 'author': 'Danimal', 'author_id': 2757, 'author_profile': 'https://Stackoverflow.com/users/2757', 'pm_score': 0, 'selected': False, 'text': '<p>It depends entirely on how the site works. I\'m in agreement with most that a sitemap is usually the best way to do it. However, if you\'re using a CMS, then you might need to keep  it in the database. If you have a taxonomy-centric site, then use the taxonomy to build the menu. There\'s no "best way" to do navigation, only the best way for a given situation.</p>\n'}, {'answer_id': 54170, 'author': 'Alvaro Rodriguez', 'author_id': 1550, 'author_profile': 'https://Stackoverflow.com/users/1550', 'pm_score': 0, 'selected': False, 'text': "<p>We've got a similar feature.</p>\n\n<p>The application menu is loaded on the master page from the database, because visible menu options depend on the user's permissions.</p>\n\n<p>A couple of conventions and clever structure on the database ensure that the menu loading code is generic and automagically navigates to the proper screen upon selection of a certain menu option. We use UIP to navigate and ComponentArt for web controls.</p>\n\n<p>BTW ComponentArt sucks. Then again I suppose all third party control libraries do.</p>\n"}, {'answer_id': 57722, 'author': 'Zack Peterson', 'author_id': 83, 'author_profile': 'https://Stackoverflow.com/users/83', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve created a site using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application.  And I\'m using a <a href="http://msdn.microsoft.com/en-us/library/yy2ykkab.aspx" rel="nofollow noreferrer">site map</a> for site navigation.</p>\n\n<p>I have ASP.NET TreeView and Menu navigation controls populated using a SiteMapDataSource.  But off-limits administrator-only pages are visible to non-administrator users.</p>\n\n<ol>\n<li><p>I created a web.sitemap site map file.  And I <a href="https://stackoverflow.com/questions/33263/how-do-i-best-handle-role-based-permissions-using-forms-authentication-on-my-as">used the ASP.NET Web Site Administration Tool to set up access rules</a>.</p></li>\n<li><p>I added navigation controls on my .master page&hellip;</p>\n\n<pre><code>&lt;asp:SiteMapPath ID="SiteMapPath1" runat="server" /&gt;\n&lt;asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource2" /&gt;\n&lt;asp:TreeView ID="TreeView1" runat="server"  DataSourceID="SiteMapDataSource1" /&gt;\n&lt;asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" /&gt;\n&lt;asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="False" /&gt;\n</code></pre></li>\n<li><p>I set securityTrimmingEnabled to "true" in my web.config file&hellip;</p>\n\n<pre><code>&lt;?xml version="1.0"?&gt;\n&lt;configuration&gt;\n    ...\n    &lt;system.web&gt;\n        ...\n        &lt;siteMap defaultProvider="default"&gt;\n            &lt;providers&gt;\n                &lt;clear/&gt;\n                &lt;add name="default"\n                    type="System.Web.XmlSiteMapProvider"\n                    siteMapFile="web.sitemap"\n                    securityTrimmingEnabled="true"/&gt;\n            &lt;/providers&gt;\n        &lt;/siteMap&gt;\n        ...\n    &lt;/system.web&gt;\n    ...\n&lt;/configuration&gt;\n</code></pre></li>\n<li><p>I adjusted the tree in the master.vb code behind file&hellip;</p>\n\n<pre><code>Protected Sub TreeView1_DataBound( ByVal sender As Object, ByVal e As EventArgs ) Handles TreeView1.DataBound\n\n    \'Collapse unnecessary menu items...\n    If TreeView1.SelectedNode IsNot Nothing Then\n        Dim n As TreeNode = TreeView1.SelectedNode\n        TreeView1.CollapseAll()\n        n.Expand()\n        Do Until n.Parent Is Nothing\n            n = n.Parent\n            n.Expand()\n        Loop\n    Else\n        TreeView1.ExpandAll()\n    End If\n\nEnd Sub\n</code></pre></li>\n</ol>\n'}, {'answer_id': 3424182, 'author': 'Roland Frank', 'author_id': 413095, 'author_profile': 'https://Stackoverflow.com/users/413095', 'pm_score': 0, 'selected': False, 'text': '<p>Efficient access is a primal feature from a user\'s perspective.\nA generic suggestive approach is\n<a href="http://bu4.taipudex.com/pinyin.htm" rel="nofollow noreferrer" title="dictionary lookup">dictionary lookup</a>,\nthat fits well for large and nested menu structures too.\nThe user navigates by clicks or unique keypresses, additionally arrow keys advance (right) or go back (left) with up/down as usual. I\'d suggest to populate the menus on request except the initial one and provide a javascript action, whenever a final element is selected.</p>\n'}]
['https://Stackoverflow.com/questions/54118', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4140/']