This tutorial shows how to implement TreeView navigation system, which is very powerful yet easy to employ. VB version.
Using TreeView for navigating with Master Pages in VB
This tutorial shows how to implement TreeView navigation system, which is very powerful yet easy to employ. VB version.
Especially for the larger sites, navigation can get a little
messy at times. Fortunately, Visual Studio makes it easier for us to
manage navigation and also construct a hierarchical navigation system
that lets users transition freely between pages, especially when it
comes to making changes to the web site.
Create an XML file containing the site hierarchy, page titles and URLs.
Web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="Home" description="Home" url="~/Default.aspx" >
<siteMapNode title="Links" description="Links to Other Sites"
url="~/Links.aspx">
<siteMapNode title="Links 1"
description="Links to sites 1" url="~/Links1.aspx" />
<siteMapNode title="Links 2"
description="Links to sites 2" url="~/Links2.aspx" />
</siteMapNode>
<siteMapNode title="Games" description="Games you can play"
url="~/Games.aspx">
<siteMapNode title="Game 1" description="Game number 1"
url="~/Game1.aspx" />
<siteMapNode title="Game 2" description="Game number 2"
url="~/Game2.aspx" />
<siteMapNode title="Game 3" description="Game number 3"
url="~/Game3.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap> |
Add a SiteMapDataSource onto your Master Page. Default configuration is set to retrieve the data from Web.sitemap
Also
add a TreeView control onto your Master Page, choosing the Data Source
of the Site Map. To also add further navigation on each page, which
displays where the current page is in the hierarcy, you can add a
SiteMapPath control. Again, by default, the SiteMapPath uses the
Web.sitemap file for its hierarchy data.
To add an expandable menu system onto the page also, add the Menu control and choose the Data Source.
The Master Page should look something like this:
<%@ Master Language="VB" AutoEventWireup="true" CodeFile="Navigation.master.vb" Inherits="Navigation" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<table style="width: 100%">
<tr>
<td style="width: 100px">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:TreeView>
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
</td>
<td style="width: 100px">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html> |
We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers
and add-ons were setup swiftly, in less than 24 hours. We were able to
confirm our order over the phone. They respond to our inquiries within
an hour. Server Intellect's customer support and assistance are the best we've ever experienced.
All content pages should have the ContentPlaceHolders for the Master Page, and look something like this:
<%@
Page Language="VB" MasterPageFile="~/Navigation.master"
AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="Default"
Title="Untitled Page" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>Home</h1>
</asp:Content> |
|