Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2012, 08:29 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Post Chapter 7 Navigation

Hi,

I'm trying to create my own Menu by following the Book's example but somehow in design view of the master page it keeps giving me "Root" instead of "Home"

Here the MenuWrapper of the frontend.master

<div id="MenuWrapper">
<asp:Menu ID="Menu1" runat="server" CssClass="MainMenu"
DataSourceID="SiteMapDataSource1">
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>


Here's the Sitemap code:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="~/" title="Home" description="Home">
<siteMapNode url="~/Default.aspx" title="Home" description="Go to Homepage" />

<siteMapNode url="~/Blogs/Default.aspx" title="Blogs" description="Blogs Describtion and Links">
<siteMapNode url="~/Blogs/NewBlog.aspx" title="New Blog" description="Create a new Blog" />
<siteMapNode url="~/Blogs/MyBlogs.aspx" title="My Blogs" description="View my Blogs" />
</siteMapNode>

<siteMapNode url="~/Browse/Default.aspx" title="Browse Blogs" description="Blogs all Blogs">
<siteMapNode url="~/Browse/ByMember.aspx" title="Browse By Member" description="Browse By Member" />
<siteMapNode url="~/Browse/ByDate.aspx" title="Browse By Date" description="Browse By Date" />
</siteMapNode>

<siteMapNode url="~/AboutUs/Default.aspx" title="About Us" description="About BlogMe">
<siteMapNode url="~/AboutUs/Default.aspx" title="BlogMe" description="About BlogMe" />
<siteMapNode url="~/AboutUs/ContactUs.aspx" title="Contact Us" description="Contact Us" />
</siteMapNode>

<siteMapNode url="~/Register.aspx" title="Register" description="Registration Page">
</siteMapNode>

<siteMapNode url="~/Help/Default.aspx" title="Help" description="Help Section">
<siteMapNode url="~/Help/Default.aspx" title="Blogging Guide" description="Blogging Guide" />
<siteMapNode url="~/Help/FAQ.aspx" title="F.A.Q." description="Frequently Asked Questions" />
</siteMapNode>

</siteMapNode>

</siteMap>


could you please point out what I did wrong?

Thanks,

Thomas
 
Old June 18th, 2012, 08:33 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Thomas,

Take a look at page 251, step 8. I think what you're after is the
ShowStartingNode property of the SiteMapDataSource control.

Cheers,

Imar

__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 18th, 2012, 08:53 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Just did that but it got me "Parent Node" in design view

Thomas
 
Old June 18th, 2012, 09:06 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could it be conflicting with the previous site (the book's site) I worked on?

Thomas
 
Old June 18th, 2012, 09:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Could it be conflicting with the previous site (the book's site) I worked on?
Not sure what you mean by that....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 18th, 2012, 09:25 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, what I meant is:

I have created the website which the book helps you create (Planet Wrox website). Now I started to create my own website using the book examples and also referring to Planet Wrox. I got stuck when I tried to create the "Menu" from the "Navigation" controls section. It seems that somehow it's not reading the "Web.sitemap"

I'm not sure if Planet Wrox's configurations are conflicting with the new website I'm working on..
 
Old June 18th, 2012, 09:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I'm not sure if Planet Wrox's configurations are conflicting with the new website I'm working on..
Not if you're not mixing code from the two project. So, as log as your new site is in its own folder, it shouldn't be influenced by the Planet Wrox web site.

Can you post the full code for the page with the Menu and the Sitemap file?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 18th, 2012, 09:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think I found it. Try requesting the page in the browser to see the error:

"Multiple nodes with the same URL '/AboutUs/Default.aspx' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs."

Not all of the pages in your sitemap file have a unique URL. The designer trips over this and only shows "Parent node". Supply unique URLs in the sitemap file and the problem should go away.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 18th, 2012, 09:35 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sure here they are:

Master page:

<%@ Master Language="VB" CodeFile="Frontend.master.vb" Inherits="MasterPages_Frontend" %>

<!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></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>



</head>
<body>
<form id="form1" runat="server">
<div id="PageWrapper">
<div id="Header">
</div>
<div id="MenuWrapper">
<asp:Menu ID="Menu1" runat="server" CssClass="MainMenu"
DataSourceID="SiteMapDataSource1">
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="False" />
</div>
<div id="MainContent">
<asp:ContentPlaceHolder ID="cpMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="Sidebar">
<p style="font-size: 12px">Select a Theme</p>
<asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True">
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Black</asp:ListItem>
</asp:DropDownList>
<p style="font-size: 5px">_____________________________________________ ______________</p>

<br />Latest Posts
<span class="style1" style="font-size: 5px">_____________________________________________ ______________</span></div>
<div id="Footer">Footer Goes Here</div>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>


SiteMap

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="~/" title="Home" description="Home">
<siteMapNode url="~/Default.aspx" title="Home" description="Go to Homepage" />

<siteMapNode url="~/Blogs/Default.aspx" title="Blogs" description="Blogs Describtion and Links">
<siteMapNode url="~/Blogs/NewBlog.aspx" title="New Blog" description="Create a new Blog" />
<siteMapNode url="~/Blogs/MyBlogs.aspx" title="My Blogs" description="View my Blogs" />
</siteMapNode>

<siteMapNode url="~/Browse/Default.aspx" title="Browse Blogs" description="Blogs all Blogs">
<siteMapNode url="~/Browse/ByMember.aspx" title="Browse By Member" description="Browse By Member" />
<siteMapNode url="~/Browse/ByDate.aspx" title="Browse By Date" description="Browse By Date" />
</siteMapNode>

<siteMapNode url="~/AboutUs/Default.aspx" title="About Us" description="About BlogMe">
<siteMapNode url="~/AboutUs/Default.aspx" title="BlogMe" description="About BlogMe" />
<siteMapNode url="~/AboutUs/ContactUs.aspx" title="Contact Us" description="Contact Us" />
</siteMapNode>

<siteMapNode url="~/Register.aspx" title="Register" description="Registration Page">
</siteMapNode>

<siteMapNode url="~/Help/Default.aspx" title="Help" description="Help Section">
<siteMapNode url="~/Help/Default.aspx" title="Blogging Guide" description="Blogging Guide" />
<siteMapNode url="~/Help/FAQ.aspx" title="F.A.Q." description="Frequently Asked Questions" />
</siteMapNode>

</siteMapNode>

</siteMap>
 
Old June 18th, 2012, 09:45 AM
Authorized User
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay thanks it worked! :) I copied the URL because I wanted that if the user clicks on either "About Us" or "About Us\Child1" it would display the same page. I'll make a copy of the page and rename it instead. Thanks again Imar, that was really helpful!

Thomas





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 Navigation Bar thepianoguy BOOK: Professional iPhone and iPad Application Development 1 March 2nd, 2011 08:32 PM
Chapter 7: Navigation Wilfredo Rosado BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 January 2nd, 2010 09:46 PM
Chapter 7 Navigation multiple sitemaps babak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 November 14th, 2008 08:15 AM
Chapter 7 Navigation Bread Crumbs AspNetGuy ASP.NET 3.5 Basics 1 April 30th, 2008 04:21 AM
Chapter 7: Navigation - Menu Control VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 12 April 10th, 2008 08:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.