Question:Master Page + siteMap

Last post 11-02-2007 10:30 AM by IMBack. 6 replies.

Sort Posts:

  • Question:Master Page + siteMap

    10-30-2007, 4:27 PM
    • Member
      293 point Member
    • IMBack
    • Member since 01-11-2007, 5:29 PM
    • Posts 411

    Hi,

     

    I am displaying a menu, with sub menu

    Websites
       - Google
       - Hotmail

    Using Master Page, SiteMap and aspx file.

    Master Page (contains)

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" enabletheming="true" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
    

     

    <table border="1" cols="2" bgcolor="aqua">

     

    <tr>

    <td>

        <asp:Menu ID="mainMenu"
                  DataSourceID="siteMapDS1"
                  runat="server"
                  StaticEnableDefaultPopOutImage="true"
                  Orientation="Horizontal"
                  StaticDisplayLevels="1"
                  MaximumDynamicDisplayLevels="1">             
       </asp:Menu>
        
        <asp:SiteMapDataSource id="siteMapDS1" runat="server" showstartingnode="true" />  
    

    </td>

    </tr>

    </table>

        </form>
    </body>
    </html>
    
     

     

    SiteMap


    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="~Default.aspx" title="Home"  description="Home page">
            <siteMapNode url="" title="Websites"  description="Form Desc" />
              <siteMapNode url="http://www.google.ca" title="google" description="descr" />
              <siteMapNode url="http://www.hotmail.com" title="hotmail" description="descr" />
        </siteMapNode>
    </siteMap>

    aspx file (default)

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Site.master" %>
    <%@ MasterType VirtualPath="~/Site.master" %>

     

    Ques:

    1. How does it interect between SiteMap and Master Page.   (how does it work behid the seen)

    2. WHen I rollover on submenu (ex.hotmail) how can I set a color so I will know which one I am currently on

    3. Only the Home (main menu) is aqua and not other sub menus. Not sure why..

    Thank you

     

  • Re: Question:Master Page + siteMap

    10-30-2007, 6:44 PM
    • Participant
      1,429 point Participant
    • MaineOne
    • Member since 01-20-2006, 1:00 AM
    • Maine
    • Posts 343

     1. The aspx and Masterpage are combined when loaded. This allows you to easily control the look of the entire site from one masterpage as apposed to changing several aspx pages. The sitemap is basically a datasource for the navigation controls.

    2. You can either create a css class to control the look and feel or you can change it on the Master page by adding

    StaticMenuItemStyle-ForeColor=DarkBlue 


                  DataSourceID="siteMapDS1"
                  runat="server"
                  StaticEnableDefaultPopOutImage="true"
                  Orientation="Horizontal"
                  StaticMenuStyle-ForeColor=DarkBlue
                  StaticDisplayLevels="1"
                  MaximumDynamicDisplayLevels="1">             
       
    3. Not sure 
    aspsksolutions.com

  • Re: Question:Master Page + siteMap

    10-31-2007, 10:50 AM
    • Member
      293 point Member
    • IMBack
    • Member since 01-11-2007, 5:29 PM
    • Posts 411

    For the first question:

    If I take away the code below from master page

    DataSourceID="siteMapDS1" and   <asp:SiteMapDataSource id="siteMapDS1" runat="server" showstartingnode="true" /> 

    --> It will not link the site map to master page. As you said sitemap is“The sitemap is basically a datasource for the navigation controls.” 

     ==================

    A. So it links as long as I put anything in DataSourceID and asp:SiteMapDataSource id  
    
    B. So my understanding .Net just knows to link it together if the datasourceId is included (by default), Is it correct?  
    
    C. But what if I have more than one sitemap ( 2 menus), how does it know which one to map to?
    
     

    THANK YOU!!

  • Re: Question:Master Page + siteMap

    11-01-2007, 2:30 AM

    Hi,

    The sitemapdatasource control can access the sitemap defaultly.

    The sitemap file name specified is web.sitemap , and the location is also fixed, viz.must be at the application's root directory.

    So event if you didnot set the  property of connecting to the datasource, the sitemapdataource also can find the sitemap file according to the default default rule. 

    So if you

    IMBack:

    take away the code below from master page

    DataSourceID="siteMapDS1" and   <asp:SiteMapDataSource id="siteMapDS1" runat="server" showstartingnode="true" /> 

    So the menu on the master page can not link to the sitemap. 

    IMBack:

    2. WHen I rollover on submenu (ex.hotmail) how can I set a color so I will know which one I am currently on

    You can set the menu's  staticselectedstyle and dynamicselectedstyle, they are used to set the selected item's style.   

     

    IMBack:

    3. Only the Home (main menu) is aqua and not other sub menus. Not sure why..

     

    You can try to use the Css Menu Adapter of the ASP.NET 2.0 CSS Friendly Control Adapters collection.

    The css menu adapter can "teach" the Menu how to produce this kind of CSS friendly HTML without sacrificing the power and flexibility of the original Menu control.control.

     

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Question:Master Page + siteMap

    11-01-2007, 11:36 AM
    • Member
      293 point Member
    • IMBack
    • Member since 01-11-2007, 5:29 PM
    • Posts 411
    Thank you for your help. 
    
    But I am still a little bit confused.
    I dont understand when you say:
    
    The sitemapdatasource control can access the sitemap defaultly. 
    1.Does this mean, it links as long as I put anything in DataSourceID and asp:SiteMapDataSource Id, and it just finds the sitemap file and links it to the master file (defaulty) Is it correct?
    
    The sitemap file name specified is web.sitemap , 
    and the location is also fixed, viz.must be at the application's root directory. 
    2. I dont have the location fixed in master file with sitemap.
     
    3.what if I have more than one sitemap ( 2 menus), how does it know which one to map to? "where is the relationship"
    
    Thank you.. 
      
     
     
  • Re: Question:Master Page + siteMap

    11-01-2007, 10:43 PM
    Answer

    Hi

    IMBack:

    The sitemapdatasource control can access the sitemap defaultly.
    1.Does this mean, it links as long as I put anything in DataSourceID and asp:SiteMapDataSource Id, and it just finds the sitemap file and links it to the master file (defaulty) Is it correct?  
      

    My answer is yes, but your sitemap file must be in the root directory, and the sitemap file's name must be web.sitemap.

    IMBack:

    The sitemap file name specified is web.sitemap ,
    and the location is also fixed, viz.must be at the application's root directory.

    2. I dont have the location fixed in master file with sitemap.
      

    In fact, it is not importent where the master page file located, the Web.sitemap file must be located in the application root directory. If the sitemap file is not in the root directory, you should do some config in the we.config file. (You can refer the code I post it at the below)

    IMBack:

    3.what if I have more than one sitemap ( 2 menus), how does it know which one to map to? "where is the relationship"
      

    If you have more than one sitemap files in the application.

    Firstly, To configure multiple site maps in the Web.config file

    For example:

    <siteMap>
       <providers>
        <add name="Web" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap"/>/// the sitemap file is in the root directory
        <add name="Web2" type="System.Web.XmlSiteMapProvider" siteMapFile="web2.sitemap"/>/// the sitemap file is in the root directory
        <add name="Web3" type="System.Web.XmlSiteMapProvider" siteMapFile="web3.sitemap"/>/// the sitemap file is in the root directory
            <add name="Web4" type="System.Web.XmlSiteMapProvider" siteMapFile="~/SiteMaps/web.sitemap"/> // the sitemap file is not in the root directory
       </providers>
      </siteMap>

    Then set the sitemap provider for sitedatasource control.

    For Example:

       this.SiteMapDataSource4.Provider =  SiteMap.Providers["Web4"];

       this.SiteMapDataSource1.Provider =  SiteMap.Providers["Web"];
       this.SiteMapDataSource2.Provider = SiteMap.Providers["Web2"];
       this.SiteMapDataSource3.Provider = SiteMap.Providers["Web3"];

    So the sitemapdatasource will link to the different sitemap files.

    You can read more in this MSDN article:  How to: Configure Multiple Site Maps and Site-Map Providers 

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Question:Master Page + siteMap

    11-02-2007, 10:30 AM
    • Member
      293 point Member
    • IMBack
    • Member since 01-11-2007, 5:29 PM
    • Posts 411

    THANK You very much!! for your help!!Smile

Page 1 of 1 (7 items)