How do I create a navigation bar accross the top of the page?

M

Mark B

I want to create a top navigation bar:

Home Products Services About Contact
>Product A
>Product B

I have been trying to use web.sitemap as the source for a menu control as
show in the example:

<?xml version="1.0" encoding="utf-8" ?>

<siteMap>
<siteMapNode title="Home" description="Home" url="~/default.aspx">
<siteMapNode title="Products" description="Our products"
url="~/Products.aspx">
<siteMapNode title="Hardware" description="Hardware choices"
url="~/Hardware.aspx" />
<siteMapNode title="Software" description="Software choices"
url="~/Software.aspx" />
</siteMapNode>
<siteMapNode title="Services" description="Services we offer"
url="~/Services.aspx">
<siteMapNode title="Training" description="Training classes"
url="~/Training.aspx" />
<siteMapNode title="Consulting" description="Consulting
services"
url="~/Consulting.aspx" />
<siteMapNode title="Support" description="Supports plans"
url="~/Support.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>

<%@ Page Language="VB" %>

<!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" >

<!-- For the hover styles of the Menu control to -->
<!-- work correctly, you must include this head -->
<!-- element. -->
<head id="Head1" runat="server">
<title>Menu DataBinding Example</title>
</head>

<body>
<form id="form1" runat="server">

<h3>Menu DataBinding Example</h3>

<!-- Bind the Menu control to a SiteMapDataSource control. -->
<asp:menu id="NavigationMenu"
disappearafter="2000"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
font-names="Arial"
target="_blank"
datasourceid="MenuSource"
runat="server">

<staticmenuitemstyle backcolor="LightSteelBlue"
forecolor="Black"/>
<statichoverstyle backcolor="LightSkyBlue"/>
<dynamicmenuitemstyle backcolor="Black"
forecolor="Silver"/>
<dynamichoverstyle backcolor="LightSkyBlue"
forecolor="Black"/>

</asp:menu>

<asp:SiteMapDataSource id="MenuSource"
runat="server"/>

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


This and other examples I have tried don't show it the way I illustrated at
the top of this email; they always seem to have the Home link as the focal
point. When I try to amend the web.sitemap to include another top-level
siteMapNode next to Home (e.g. Products) the XML gives an error.

Any idea why this is?

TIA
 
M

Madhur

Mark B said:
I want to create a top navigation bar:

Home Products Services About Contact

I have been trying to use web.sitemap as the source for a menu control as
show in the example:

<?xml version="1.0" encoding="utf-8" ?>

<siteMap>
<siteMapNode title="Home" description="Home" url="~/default.aspx">
<siteMapNode title="Products" description="Our products"
url="~/Products.aspx">
<siteMapNode title="Hardware" description="Hardware choices"
url="~/Hardware.aspx" />
<siteMapNode title="Software" description="Software choices"
url="~/Software.aspx" />
</siteMapNode>
<siteMapNode title="Services" description="Services we offer"
url="~/Services.aspx">
<siteMapNode title="Training" description="Training classes"
url="~/Training.aspx" />
<siteMapNode title="Consulting" description="Consulting
services"
url="~/Consulting.aspx" />
<siteMapNode title="Support" description="Supports plans"
url="~/Support.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>

<%@ Page Language="VB" %>

<!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" >

<!-- For the hover styles of the Menu control to -->
<!-- work correctly, you must include this head -->
<!-- element. -->
<head id="Head1" runat="server">
<title>Menu DataBinding Example</title>
</head>

<body>
<form id="form1" runat="server">

<h3>Menu DataBinding Example</h3>

<!-- Bind the Menu control to a SiteMapDataSource control. -->
<asp:menu id="NavigationMenu"
disappearafter="2000"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
font-names="Arial"
target="_blank"
datasourceid="MenuSource"
runat="server">

<staticmenuitemstyle backcolor="LightSteelBlue"
forecolor="Black"/>
<statichoverstyle backcolor="LightSkyBlue"/>
<dynamicmenuitemstyle backcolor="Black"
forecolor="Silver"/>
<dynamichoverstyle backcolor="LightSkyBlue"
forecolor="Black"/>

</asp:menu>

<asp:SiteMapDataSource id="MenuSource"
runat="server"/>

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


This and other examples I have tried don't show it the way I illustrated
at the top of this email; they always seem to have the Home link as the
focal point. When I try to amend the web.sitemap to include another
top-level siteMapNode next to Home (e.g. Products) the XML gives an error.

Any idea why this is?

Home is the focal point, because in your XML. Home is a top level node and
it has got childs.

As an idea, you need to modify your sitemap XML like this
 
M

Mark B

I get :

"Parser Error Message: The XML sitemap config file web.sitemap could not be
loaded. The 'siteMap' start tag on line 3 does not match the end tag of
'siteMapNode'. Line 21, position 7.
 
M

Mark B

And if I delete that last / I get:

"Exactly one <siteMapNode> element is required directly inside the <siteMap>
element. "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top