Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : 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 May 31st, 2016, 06:00 PM
Registered User
 
Join Date: May 2016
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Chapter7: SiteMapPath Not displaying in browser

In the SiteMapPath Try It Out, the site map does not display in the browser although I can see it in Design View. I copied the Frontend.master code and the Default.aspx code from the source files for chapter 7 (in case I typed something wrong), but still the same result. Am I missing something?
 
Old May 31st, 2016, 06:05 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Did you create the sitemap.xml file? Can you provide more information such as the code for site map.xml, web.config, and the master page's markup and code behind?

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 2nd, 2016, 02:55 PM
Registered User
 
Join Date: May 2016
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi! Thank you for your prompt response!

I don't recall having to create sitemap.xml file. I created the Web.sitemap file (copied the code from the Source). Every other exercise has worked so far...

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" title="Home" description="Go to the homepage" />
    <siteMapNode url="~/Reviews/Default" title="Reviews" description="Reviews published on this site">
      <siteMapNode url="~/Reviews/AllByGenre" title="By Genre" description="All Reviews Grouped by Genre" />
      <siteMapNode url="~/Reviews/All" title="All Reviews" description="All Reviews" />
    </siteMapNode>
    <siteMapNode url="~/About/Default" title="About" description="About this Site">
      <siteMapNode url="~/About/Contact" title="Contact Us" description="Contact Us" />
      <siteMapNode url="~/About/AboutUs" title="About Us" description="About Us" />
    </siteMapNode>
    <siteMapNode url="~/Login" title="Login" description="Log in to this web site" />
  </siteMapNode>
</siteMap>

This is the code for the Frontend.master (again copied from the source to make sure I didn't have a typo):

Code:
<%@ Master Language="VB" CodeFile="Frontend.master.vb" Inherits="MasterPages_Frontend" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
  <asp:ContentPlaceHolder ID="head" runat="server">
  </asp:ContentPlaceHolder>
  <script src="/Scripts/modernizr-2.7.1.js"></script>
</head>
<body>
  <form id="form1" runat="server">
    <div id="PageWrapper">
      <header><a href="/"></a></header>
      <nav>
        <asp:Menu ID="Menu1" runat="server" CssClass="MainMenu" Orientation="Horizontal" DataSourceID="SiteMapDataSource1" StaticEnableDefaultPopOutImage="False">
        </asp:Menu>
        <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ShowExpandCollapse="False">
          <LevelStyles>
            <asp:TreeNodeStyle CssClass="FirstLevelMenuItems" />
          </LevelStyles>
        </asp:TreeView>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
      </nav>
      <section id="MainContent">
        <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>
        <br />
        <br />
        <asp:ContentPlaceHolder ID="cpMainContent" runat="server">
        </asp:ContentPlaceHolder>
      </section>
      <aside id="Sidebar">
        Select a theme
        <br />
        <asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True">
          <asp:ListItem>Monochrome</asp:ListItem>
          <asp:ListItem>DarkGrey</asp:ListItem>
        </asp:DropDownList>
      </aside>
      <footer>Footer Goes Here</footer>
    </div>
  </form>
</body>
</html>
and this is the Code behind for the Master page:

Code:
Partial Class MasterPages_Frontend
    Inherits System.Web.UI.MasterPage

  Protected Sub ThemeList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ThemeList.SelectedIndexChanged
    Dim preferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
    preferredTheme.Expires = DateTime.Now.AddMonths(3)
    preferredTheme.Value = ThemeList.SelectedValue
    Response.Cookies.Add(preferredTheme)
    Response.Redirect(Request.Url.ToString())
  End Sub

  Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
      Dim selectedTheme As String = Page.Theme
      Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
      If preferredTheme IsNot Nothing Then
        selectedTheme = preferredTheme.Value
      End If
      If Not String.IsNullOrEmpty(selectedTheme) Then
        Dim item As ListItem = ThemeList.Items.FindByValue(selectedTheme)
        If item IsNot Nothing Then
          item.Selected = True
        End If
      End If
    End If

    Select Case Page.Theme.ToLower()
      Case "darkgrey"
        Menu1.Visible = False
        TreeView1.Visible = True
      Case Else
        Menu1.Visible = True
        TreeView1.Visible = False
    End Select
  End Sub
End Class

And this is the Web.config

Code:
<?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>
      <pages theme="Monochrome" />
      <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.1" />
      <httpRuntime targetFramework="4.5.1" />
    </system.web>

</configuration>
 
Old June 6th, 2016, 06:39 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 there,

>> I don't recall having to create sitemap.xml file.

Sorry, my bad. I was working on another project that has a sitemap.xml file; the right name should indeed be web.sitemap.

I copied and pasted your code into my Planet Wrox project and it works well. On the homepage I see Home and on a page like Reviews I see Home > Reviews.

Could it be that your CSS is hiding the links? What if you look in the browser's source HTML. Do you see the site map path there?

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 6th, 2016, 09:18 AM
Registered User
 
Join Date: May 2016
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default

It looks like it is in the browser's HTML (below is the code). I have tried both IE and Chrome. I don't know if this could be the reason, but I have been unable to download any of the Nuget Packages.

Code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
	Welcome to Planet Wrox
</title>

  <script src="/Scripts/modernizr-2.7.1.js"></script>
<link href="App_Themes/Monochrome/Monochrome.css" type="text/css" rel="stylesheet" /><style type="text/css">
	/* <![CDATA[ */
	#Menu1 img.icon { border-style:none;vertical-align:middle; }
	#Menu1 img.separator { border-style:none;display:block; }
	#Menu1 img.horizontal-separator { border-style:none;vertical-align:middle; }
	#Menu1 ul { list-style:none;margin:0;padding:0;width:auto; }
	#Menu1 ul.dynamic { z-index:1; }
	#Menu1 a { text-decoration:none;white-space:nowrap;display:block; }
	#Menu1 a.static { padding-left:0.15em;padding-right:0.15em; }
	#Menu1 a.popout-dynamic { background:url("/WebResource.axd?d=YAYach_zykzn7tRotFpEUuqlVaNN6-w756-dIOiWHUmzjBX_pkJE98pECH-cxDsqAc01igGkKNHkhyUO5lsbZV63Z-zIEpdIGss_j5T3KpQ1&t=635803038500000000") no-repeat right center;padding-right:14px; }
	/* ]]> */
</style></head>
<body>
  <form method="post" action="./Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden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CUFEULQ/gk3i2aWXYEErxsAXeMaE2gAPLDNajIRAVBEIahEFjCeUTXVXY5u+W8FAlRcf/NvsLEeIEu5PDFMQcsqJ+hD0o2Uk9H6LC1U5Fy5sg9I7XVfIOD5XS40h9zQmBWpYfVXu9hqz+kBwQ68rWsKzQweTH1rgLmhqk1gHqtgFR7MwDjzZa03mnArFKQDQA9zdrOkKblOa6axcdUl2T766vry1WyfLhCtrJdEuZ8pJrrEwMtEVFu6EX4QeGlc3Nj4Q/VnQGBR53PVhQSs5KMSJfF5E0Tk9k9HdS6611EXLm3qUC1ENHGCYpi8I7NNtgKXmNsYo+j3JRnOuQT/adMtIuMFqqtGaED/tFYV+EzLEDEQDr5bZlpRJx/DICXhpT2H1y2i+D471eQb+Xhr0lXfyp8FRx/hlFAyCOMMkIqhq1IV+ewOA7/o=" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>



<script src="/WebResource.axd?d=fqV81KWLWhVg-lLAb4IT6xxTgeNv90BtxehlIpnXZwSNkUz5g6jK_7N5l9N5ZYu4ybz75Fk9sKs7cdKHQej5O0HiaLOjuQqJuBaycpxxNhA1&amp;t=635803038500000000" type="text/javascript"></script>
    <div id="PageWrapper">
      <header><a href="/"></a></header>
      <nav>
        <a href="#Menu1_SkipLink" style="position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;">Skip Navigation Links</a><div class="MainMenu" id="Menu1">
	<ul class="level1">
		<li><a title="Go to the homepage" class="level1" href="/Default">Home</a></li><li><a title="Reviews published on this site" class="level1" href="/Reviews/Default">Reviews</a><ul class="level2">
			<li><a title="All Reviews Grouped by Genre" class="level2" href="/Reviews/AllByGenre">By Genre</a></li><li><a title="All Reviews" class="level2" href="/Reviews/All">All Reviews</a></li>
		</ul></li><li><a title="About this Site" class="level1" href="/About/Default">About</a><ul class="level2">
			<li><a title="Contact Us" class="level2" href="/About/Contact">Contact Us</a></li><li><a title="About Us" class="level2" href="/About/AboutUs">About Us</a></li>
		</ul></li><li><a title="Log in to this web site" class="level1" href="/Login">Login</a></li>
	</ul>
</div><a id="Menu1_SkipLink"></a>
        
        
      </nav>
      <section id="MainContent">
        <span id="SiteMapPath1"><a href="#SiteMapPath1_SkipLink" style="position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;">Skip Navigation Links</a><a id="SiteMapPath1_SkipLink"></a></span>
        <br />
        <br />
        
  <h1>Hi there visitor and welcome to Planet Wrox</h1>
  <p class="Introduction">We're glad you're paying a visit to <a href="http://www.PlanetWrox.com">www.PlanetWrox.com</a>, the coolest music community site on the Internet.</p>
  <p class="Introduction">Feel free to have a <a href="Default">look around</a>; there are lots of interesting <strong>reviews and concert pictures</strong> to be found here.</p>
  <p>You can <a href="Login">log in</a> here</p>

      </section>
      <aside id="Sidebar">
        Select a theme
        <br />
        <select name="ctl00$ThemeList" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ThemeList\',\'\')', 0)" id="ThemeList">
	<option selected="selected" value="Monochrome">Monochrome</option>
	<option value="DarkGrey">DarkGrey</option>

</select>
        <br />
        <br />
        <br />
        <div id="Banner1_VerticalPanel">
	
  <a href="http://p2p.wrox.com" id="Banner1_VerticalLink" target="_blank">
    <img id="Banner1_Image1" src="Images/Banner120x240.gif" alt="This is a sample banner" />
  </a>

</div>




      </aside>
      <footer>Footer Goes Here</footer>
    </div>
  
<div class="aspNetHidden">

	<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/rUqaj6xHVGFFiKGPhEr3THPILs014eEaqzKRP9PQj0JWjmn4LQfo3iK0Jbw0bVNwdxru8ukeZzrerEVRmxKSu5fCOkOCYA7uKawL2fHxC8ukA0TaSCwbaBXbiKPwxVlIb3aBuKqB1fVjT/2n9ljQGXvByR2ClpA8PQhrQMZ5Ug=" />
</div>
<script type='text/javascript'>new Sys.WebForms.Menu({ element: 'Menu1', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });</script></form>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Chrome","requestId":"b486eb813ae24d0d9ccb327808a603f9"}
</script>
<script type="text/javascript" src="http://localhost:53987/e6411187108c4ae087cbdade60615352/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>
 
Old June 7th, 2016, 07:52 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 don't know if this could be the reason, but I have been unable to download any of the Nuget Packages.

Ah, so maybe you don't have the friendly URL packages and therefor the site map doesn't respond to the extension-less URLs? Try adding .aspx to your URLs in web.sitemap.

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!
The Following User Says Thank You to Imar For This Useful Post:
TI2016 (June 7th, 2016)
 
Old June 7th, 2016, 09:11 AM
Registered User
 
Join Date: May 2016
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thank you! It works now.
 
Old November 9th, 2016, 10:53 AM
Registered User
 
Join Date: Nov 2016
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar, adding .aspx to all URL in the web.sitemap works for me.

<?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 the homepage" />
<siteMapNode url="~/Reviews/Default.aspx" title="Reviews" description="Reviews published on this site">
<siteMapNode url="~/Reviews/AllByGenre.aspx" title="By Genre" description="All Reviews Grouped by Genre" />
<siteMapNode url="~/Reviews/All.aspx" title="All Reviews" description="All Reviews" />
</siteMapNode>
<siteMapNode url="~/About/Default.aspx" title="About" description="About this Site">
<siteMapNode url="~/About/Contact.aspx" title="Contact Us" description="Contact Us" />
<siteMapNode url="~/About/AboutUs.aspx" title="About Us" description="About Us" />
</siteMapNode>
<siteMapNode url="~/Login.aspx" title="Login" description="Log in to this web site" />
</siteMapNode>
</siteMap>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Page 241 Chapter7 No Page button is showing on browser. tota1ecl1pse BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 September 18th, 2009 01:03 PM
Displaying < and > in browser csummers XSLT 1 January 24th, 2008 08:49 PM
error when displaying messagebox on client browser alexdcosta ASP.NET 2.0 Basics 5 June 24th, 2006 12:41 PM
web control not displaying in browser rj1406 ASP.NET 1.0 and 1.1 Basics 8 September 19th, 2004 05:32 AM
Displaying Excel in Browser sundar_revathi General .NET 0 July 7th, 2004 03:17 PM





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