Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey !
ive encountered with a amateur , ambiguous issue about asp.net menu control .
i made a web.sitemap file as shown here :
XML
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode title="main">
    <siteMapNode title="Home" description="Home" url="~/default.aspx">
    </siteMapNode>
    <siteMapNode title="Products" description="">
      <siteMapNode title="mobile" description="Our products" url="~/mobile.aspx">
        <siteMapNode title="web based"   url="~/webbased.aspx" />
        <siteMapNode title="windows"   url="~/windows.aspx" />
      </siteMapNode>
    </siteMapNode>
  </siteMapNode>
</siteMap>


and i want a menu control show it horizontally ... i wrote these simple lines :
ASP.NET
<div id="Menu" style="padding :20px;">
       <asp:Menu ID="Menu1" Runat="server" 
            DataSourceID="SiteMapDataSource"
            Orientation="Horizontal">
      </asp:Menu>
      <asp:SiteMapDataSource ID="SiteMapDataSource" runat="server"/>
</div>


but it always show items vertically and submenus and parent menus listed as below :
VB
main
Home
Products
mobile
web based
windows


but it should be something like this :
XML
Home Products▼ 


in design time everything is as my wish but when i run it on any browser , menu showed me items as list, menus and submenus in vertically list... it dnt show me horizontally at all !

whats the problem ... can anyone help me?
thanks all to spending time!
Posted
Updated 19-Mar-13 6:33am
v3

Hi! Hope this solves your problem!!! i've checked this in my local env. it's working as you expected..

XML
<asp:Menu ID="Menu1" runat="server" orientation="Horizontal" StaticDisplayLevels="2" datasourceid="SiteMapDataSource1">
    </asp:Menu>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />


and in sitemap file
XML
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="Home" description="Home">
    <siteMapNode title="Home" description="Home" url="~/default.aspx" />
    <siteMapNode title="Products" description="">
      <siteMapNode title="mobile" description="Our products" url="~/mobile.aspx">
        <siteMapNode title="web based"   url="~/webbased.aspx" />
        <siteMapNode title="windows"   url="~/windows.aspx" />
      </siteMapNode>
    </siteMapNode>
  </siteMapNode>
</siteMap>

Ref:http://msdn.microsoft.com/en-us/library/ecs0x9w5(v=vs.80).aspx[^]
Mark it if you find this useful!!
~~SATZ~~
 
Share this answer
 
v2
Comments
ali_heidari_ 20-Mar-13 16:16pm    
THANKS MY problem solved ... problem was with my browsers ! i unistall the google chrome and reinstal it ... but with anonymous reason problem solved on all of my browsers!
Did you add provider?... in web.config???

XML
<siteMap>
            <providers>
                <add name="MainWebSitemap" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
            </providers>
</siteMap>


and mapped this to the
<asp:SiteMapDataSource
tag?
 
Share this answer
 
v2
Comments
ali_heidari_ 19-Mar-13 7:13am    
problem is not provier... sitemapdatasource will use web.sitemap file as default .... this provider you suggest is default.
anyway i used your advice but resault was as same before. items listed not like a menu with floating submenu .

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900