?
Solved

example in multiple sitemap

Posted on 2007-10-09
9
Medium Priority
?
523 Views
Last Modified: 2013-11-07
In ASP.NET 2.0 with C# I needs an example to see how to deal with multiple site Map
I don;t want to switch between the sitemap files but I want to use one file in a certain place and another file in another place.
I thought of declaring a main web.sitemap like this:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
      <siteMapNode  title="rootHome"  url="~/default.aspx?p=304" description="">
            <siteMapNode siteMapFile="source.sitemap" />
            <siteMapNode siteMapFile="Everything.sitemap" />
      </siteMapNode>
</siteMap>
and then use it as requested.
In the code behind I tried to have a loop to have data only on the source file but I get problems in the looping
Thankyou
Anat
0
Comment
Question by:ANAT2403
  • 6
  • 2
9 Comments
 
LVL 16

Expert Comment

by:McExp
ID: 20043289
So, to get this right, you need to be able to traverse the nested sitemaps in your codebehind?

The declarative controls all deal with this automatically.

What is the goal of your code-behind?
0
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
ID: 20043323
0
 
LVL 16

Accepted Solution

by:
McExp earned 2000 total points
ID: 20043443
I'm guessing what you require is a recursive function to traverse the SiteMap, Below is an example.

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ProcessChildNodes(SiteMap.RootNode);
    }

    private void ProcessChildNodes(SiteMapNode node)
    {
        foreach (SiteMapNode childNode in node.ChildNodes)
        {
            //Do Something to node?
            //Response.Write(childNode.Title + "\r\n");
            ProcessChildNodes(childNode);
        }
    }
}
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 16

Expert Comment

by:McExp
ID: 20043494
The following code if passed the SiteMap.RootNode will render a nested bulleted list which should depict the entire site including all sub sitemap files

    private void ProcessChildNodes(SiteMapNode node)
    {
        Response.Write("<ul>\r\n");
        foreach (SiteMapNode childNode in node.ChildNodes)
        {
            Response.Write("<li>" + childNode.Title + "</li>\r\n");
            if (childNode.ChildNodes.Count > 0)
            {
                ProcessChildNodes(childNode);
            }
        }
        Response.Write("</ul>\r\n");
    }
0
 

Author Comment

by:ANAT2403
ID: 20045005
I will explain again:
I have in the web.sitemap 2 sitemap file. suppose I want to show in a menu bar the content of source.sitemap
 and in a left pane the everything.sitemp.
The dealing with source.sitemap is done in thte code behind but I want to deal only with the first node of web.sitemap. The dealing with the everything sitempais done by a repeater directly  in a code and there th question is how to declare it?
this is the way I declared it:


             <asp:Repeater runat="server" ID="LeftMenu"   DataSourceID="SiteMapDataSource1">
                        <ItemTemplate>
                            <div class="field_line_wrap">
                                <div class="field_header">
                                    <asp:HyperLink ID="HyperLink1" runat="server"  NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>
                                    </asp:HyperLink>
                                </div>
 
                                <asp:Repeater runat="server" ID="LeftsubMenu"     DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
                                    <ItemTemplate>
                                        <div class="field_products">
                                           <asp:HyperLink ID="HyperLink2" runat="server"  NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>
                                           </asp:HyperLink>
                                        </div>
                                                    <div class="separator">|</div>
                                   </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </ItemTemplate>
                </asp:Repeater>
             
                     
0
 
LVL 16

Expert Comment

by:McExp
ID: 20045148
The contents of everything.sitemap is a sibling of source.sitemap not a child node as your implimentation requires
0
 
LVL 16

Expert Comment

by:McExp
ID: 20045350
I assume that For each node in source.sitemap there is a number of child nodes which you have stored in Everything.Sitemap?

Does Everything.Sitemap contain all nodes? including all nodes in source.sitemap?

I think if you Structure the sitemap so that it maps to the correct hierachy of your site the code sample above should work?
0
 

Author Comment

by:ANAT2403
ID: 20046398
Hi,
I don't want that the source.sitemap and everything .sitemap will be connected.
I want to have in my site 2 independent sitemaps that will be used in the same page. but because I know the rule that every sitemap has to have one web.sitemap I thought of putting them together. but I need to 2 seperate sitemaps. how do I implement this? Maybe I should start from a different direction. Please advise!
Anat
0
 
LVL 16

Expert Comment

by:McExp
ID: 20047303
Why do you need two seperate site maps? I don't think you are using the site map as intended? Could you post the contents of the two sitemaps so I can get a feel for why you have taken the approach you have?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question