show/hiding menuitems, how?

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net 2.0

I'm wondering how to configure the menu and the sitemapdatasource so that it
hides the elements at 3. level (that is elements like test4, test5 and
test6).

In addition I want to be able to click on test3 and then let the subelements
appear again.. under test3..

I'm looking for a way of doing this generic, the data below is just an
example... I think one way is to hide is to put some logic into the
DataBound event of the menu... - don't add elements at a specific layer
there... I don't want to have to perform a test like "if element=test3" then
hide/not render the menu elements...

any ideas?

I have this menu:
<asp:Menu ID="Menu2" runat="server" SkinID="menu"
CssClass="menu"
DataSourceID="smdsWord"
StaticDisplayLevels="3" OnDataBound="Menu2_DataBound"
Orientatio="vertical">
</asp:Menu></div>
<asp:SiteMapDataSource ID="smdsWord" runat="server"
ShowStartingNode="false"
SiteMapProvider="Word" />

and this sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="test1.aspx" title="1" description="">
<siteMapNode url="test2.aspx" title="test2" description="" />
<siteMapNode url="test3.aspx" title="test3" description="" >
<siteMapNode url="test4.aspx" title="tes4" description="" />
<siteMapNode url="test5.aspx" title="test5" description="" />
<siteMapNode url="test6.aspx" title="test6" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
 
hi

asp.net 2.0

I'm wondering how to configure the menu and the sitemapdatasource so thatit
hides the elements at 3. level (that is elements like test4, test5 and
test6).

In addition I want to be able to click on test3 and then let the subelements
appear again.. under test3..

I'm looking for a way of doing this generic, the data below is just an
example...  I think one way is to hide is to put some logic into the
DataBound event of the menu... - don't add elements at a specific layer
there... I don't want to have to perform a test like "if element=test3"then
hide/not render the menu elements...

any ideas?

I have this menu:
<asp:Menu ID="Menu2" runat="server" SkinID="menu"
 CssClass="menu"
 DataSourceID="smdsWord"
 StaticDisplayLevels="3" OnDataBound="Menu2_DataBound"
 Orientatio="vertical">
</asp:Menu></div>
<asp:SiteMapDataSource ID="smdsWord" runat="server"
ShowStartingNode="false"
SiteMapProvider="Word" />

and this sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="test1.aspx" title="1"  description="">
    <siteMapNode url="test2.aspx" title="test2"  description="" />
    <siteMapNode url="test3.aspx" title="test3"  description="" >
      <siteMapNode url="test4.aspx" title="tes4"  description="" />
      <siteMapNode url="test5.aspx" title="test5"  description="" />
      <siteMapNode url="test6.aspx" title="test6"  description="" />
    </siteMapNode>
  </siteMapNode>
</siteMap>

You can do this by enabling security trimming

Here's an example
http://msdn.microsoft.com/en-us/library/ms178428.aspx
http://blogs.msdn.com/tolong/archive/2007/02/11/how-to-hide-your-sitemap-links.aspx

Hope this helps
 
Back
Top