SiteMapPath, Menu e TreeView

<< Click to Display Table of Contents >>

Navigation:  ASP.NET > ASP Controls >

SiteMapPath, Menu e TreeView

Previous pageReturn to chapter overviewNext page

Os 3 componentes (Sitemap, Menu e TreeView):

 

'menusitemap

 

SitemapPath

 

menu2

 

Crie várias aspx na estrutura:

 

menu3

 

Crie um arquivo do tipo Web.sitemap

 

<?xml version="1.0" encoding="utf-8" ?>

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

 <siteMapNode url="~/Default.aspx" title="Principal" description="">

 

   <siteMapNode url="~/Eletronicos/Eletronicos.aspx" title="Eletrônicos" description="">

     <siteMapNode url="~/Eletronicos/PS3.aspx" title="PS3" description="PlayStations 3" />

     <siteMapNode url="~/Eletronicos/TV.aspx" title="TVs" description="Televisões" />

   </siteMapNode>

 

   <siteMapNode url="~/Informatica.aspx" title="Setor Informática" description="Coisas interessantes">

     <siteMapNode url="~/Informatica/Monitores/LCD.aspx" title="LCD" description="Antigo" />

     <siteMapNode url="~/Informatica/Monitores/LED.aspx" title="LED" description="Novo" />

   </siteMapNode>

   

 </siteMapNode>

</siteMap>

 

 

Default.aspx

 

  <form id="form1" runat="server">

  <div>

      <asp:SiteMapPath ID="SiteMapPath2" runat="server" Font-Names="Verdana" Font-Size="0.8em"

          PathSeparator=" : ">

          <CurrentNodeStyle ForeColor="#333333" />

          <NodeStyle Font-Bold="True" ForeColor="#666666" />

          <PathSeparatorStyle Font-Bold="True" ForeColor="#1C5E55" />

          <RootNodeStyle Font-Bold="True" ForeColor="#1C5E55" />

      </asp:SiteMapPath>

      <br />

      <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

      <br />

      <asp:Menu ID="Menu1" runat="server" BackColor="#B5C7DE" DataSourceID="SiteMapDataSource1"

          DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98"

          Orientation="Horizontal" StaticSubMenuIndent="10px">

          <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />

          <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

          <DynamicMenuStyle BackColor="#B5C7DE" />

          <DynamicSelectedStyle BackColor="#507CD1" />

          <StaticHoverStyle BackColor="#284E98" ForeColor="White" />

          <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

          <StaticSelectedStyle BackColor="#507CD1" />

      </asp:Menu>

      <br />

      <br />

      <br />

      <br />

  </div>

  <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ImageSet="BulletedList4"

      ShowExpandCollapse="False">

      <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />

      <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"

          NodeSpacing="0px" VerticalPadding="0px" />

      <ParentNodeStyle Font-Bold="False" />

      <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"

          VerticalPadding="0px" />

  </asp:TreeView>

  </form>

 

Observações

 

Para testar coloque um SiteMapPath em todas as páginas aspx ou numa masterpage.