Click here to Skip to main content
15,906,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i had develop the asp.net project.This project has two members
admin,student.i had maintain two master pages with corresponding menu controls for member activities(admin,student).i used two sitemap files (Web.sitemap,student.sitemap)
i was configure the multiple sitemaps in one web configure file.i bind the student member activities to menu control(with in student masterpage)using sitemap but instead of admin activities are bind automatically to student master page i.e functionality second menu not working properly.two master pages are also bind the admin activities but i want to bind the activities for corresponding master pages by using sitemap and menu control.

Web.sitemap


C#
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title=""  description="">
         <siteMapNode url="Admin.aspx" title="Home"  description="Home page" />
        <siteMapNode url="StudentRegistration.aspx" title="Student registration"  description="Studentregistration page" />
         <siteMapNode url="AddLearningmaterial.aspx" title="Add material" description="AddLearningmaterial">
             <siteMapNode url="Alphabets.aspx" title="Alphabets" description="Alphabets page"></siteMapNode>
             <siteMapNode url="Numbers.aspx" title="Numbers" description="Numbers page"></siteMapNode>
             <siteMapNode url="Animals.aspx" title="Animals" description="Animals page"></siteMapNode>
             <siteMapNode url="Fruits.aspx" title="Fruits" description="Fruits page"></siteMapNode>
             <siteMapNode url="Vegetables.aspx" title="Vegetables" description="Vegetables page"></siteMapNode>
         </siteMapNode>
        <siteMapNode url="Modifyingmaterial.aspx" title="Update material" description="Modifyingmaterial page"></siteMapNode>
    <!--<siteMapNode siteMapFile="student.sitemap"/>-->      
    </siteMapNode>
</siteMap>


student.sitemap
C#
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
 <siteMapNode url="" title=""  description="">
  <siteMapNode url="Home.aspx" title="Home"  description="Home page" />
  <siteMapNode url="Viewmaterial.aspx" title="View material"  description="Viewmaterial page" >
    <siteMapNode url="ViewAlphabets.aspx" title="Alphabets" description="Alphabets page"></siteMapNode>
    <siteMapNode url="viewNumbers.aspx" title="Numbers" description="Numbers page"></siteMapNode>
    <siteMapNode url="viewAnimals.aspx" title="Animals" description="Animals page"></siteMapNode>
    <siteMapNode url="viewFruits.aspx" title="Fruits" description="Fruits page"></siteMapNode>
    <siteMapNode url="viewVegetables.aspx" title="Vegetables" description="Vegetables page"></siteMapNode>
   </siteMapNode>
    </siteMapNode>
</siteMap>


Configure multiple site maps in webconfig File:
C#
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <siteMap defaultProvider="SiteMapDataSource1">
      <providers>
        <clear/>
       <add name="SiteMapDataSource1" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" />
    <add name="SiteMapDataSource2" type="System.Web.XmlSiteMapProvider" siteMapFile="student.sitemap" />
      </providers>
    </siteMap>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>




Admin.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Admin.master.cs" Inherits="Admin" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 <style type="text/css">
    body
    {
        font-family: Arial;
        font-size: 10pt;
    }
    .main_menu
    {
        width:240px;
        font-size:x-large;
        background-color: #8AE0F2;
        color: #000;
        text-align: center;
        height: 30px;
        line-height: 30px;
        margin-right: 5px;
    }
    .level_menu
    {
        width:257px;
        font-size:large;
        background-color: #000;
        color: #fff;
        text-align: center;
        height: 30px;
        line-height: 30px;
        margin-top: 5px;
    }

    .selected
    {
        background-color: #852B91;
        color: #fff;
    }
    /*.sub_menu
   {
        width: 110px;
        background-color: #000;
        color: #fff;
        text-align: center;
        height: 30px;
        line-height: 30px;
        margin-top: 5px;
   }
    .hover_menu
   {
        background-color: #990000;
        color:#fff;
   }
    .selected_menu
   {
      background-color: #FF6600;
   }*/
</style>
    <asp:ContentPlaceHolder id="head" runat="server">

    </asp:ContentPlaceHolder>
</head>
<body>
   <form id="form1" runat="server">
    <asp:Image ID="ImgELearn"  runat="server" AlternateText="E-Learning" Height="202px" ImageUrl="~/Images/Title logo.png" Width="1020px"  />    
       <div class="user">
           <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
           <asp:Menu ID="Menu" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal"
    OnMenuItemDataBound="OnMenuItemDataBound">
    <LevelMenuItemStyles>
        <asp:MenuItemStyle CssClass="main_menu" />
        <asp:MenuItemStyle CssClass="level_menu" />       
    </LevelMenuItemStyles>
 <%--<DynamicMenuItemStyle CssClass="sub_menu" />
<DynamicHoverStyle CssClass="hover_menu" />
<StaticSelectedStyle CssClass="selected_menu" />
<StaticHoverStyle CssClass="hover_menu" />--%>

</asp:Menu>
       </div>  
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>



Student.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Student.master.cs" Inherits="Student" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
 <form id="form1" runat="server">
    <asp:Image ID="ImgELearn"  runat="server" AlternateText="E-Learning" Height="202px" ImageUrl="~/Images/Title logo.png" Width="1020px"  />
     <div class="data">
      <asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="false" />
         <%--<asp:SiteMapPath ID="SiteMapPath1"  runat="server" PathSeparator=" > " RenderCurrentNodeAsLink="false">
</asp:SiteMapPath>--%>
         <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource2" Orientation="Horizontal"
    OnMenuItemDataBound="OnMenuItemDataBound">
    <LevelMenuItemStyles>
        <asp:MenuItemStyle CssClass="main_menu" />
        <asp:MenuItemStyle CssClass="level_menu" />       
    </LevelMenuItemStyles>
       </asp:Menu>
         
     </div>
 
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>


This is my code.I think way of developing the project is correct but i felt small
mistake according sitemap,menu control and web.config configuration.if u know,pls correct the code. i don't know what is the xmlsitemap defaultProvider.pls give me about defaultProvider and also give about name attributes in add tag in detail.
i confused name attributes names what i am given.pls check once.help me.

What I have tried:

i was configure the multiple sitemaps in one web configure file.i bind the student member activities to menu control(with in student masterpage)using sitemap but instead of admin activities are bind automatically to student master page i.e functionality of second menu not working properly.two master pages are also bind the admin activities but i want to bind the activities for corresponding master pages by using sitemap and menu control.
Posted
Updated 13-Jan-17 3:52am
v10
Comments
Krishna Veni 13-Jan-17 7:10am    
Please Help me.it's urgent

1 solution

The SiteMapDataSource control[^] will, by default, bind to the default site map provider, as specified in the web.config file.

You've set defaultProvider="SiteMapDataSource1", which points to Web.sitemap, so both SiteMapDataSource controls will use that site map by default.

To use a different site map, you need to set the SiteMapProvider property[^] to the name of the site map provider you'd like to use:
<asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" 
    ShowStartingNode="false" 
    SiteMapProvider="SiteMapDataSource2"
/>

NB: The ID of the SiteMapDataSource control is not connected in any way to the name of the site map provider. Setting both to the same string won't connect them. The only way to change the provider is to use the SiteMapProvider property in markup, or the Provider property[^] from your code-behind.
 
Share this answer
 

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