Community-Credit.com | NonProfitWays.com | SOAPitstop.com   Skin:   
      User: Not logged in 
Home
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Presentations
Featured Articles
Book Chapters
Training Courses
Events
NewsGroups
 
Discussions
Examples
Tutorials
Tools
Articles
Resources
Websites
 
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
Logout
 
About Me
My Blog
HeadGeek Articles
Talking Portfolio
Resume
Pictures
World Trip Pics

AnimalsSiteNavigator in ASP.NET 2.0
Author: Unknown
Published: 7/2/2005 6:02 PM
Category: ADO.NET, ASP.NET, Database, VB.NET, VS.NET
Summary: Let you navigating to different site of Animals

 

1)ArtistDB.VB

Imports System

Imports System.Data

Imports System.Data.SqlClient

' <summary>

' Fetches ArtistID and ArtistName from One Ear Society Artists

' </summary>

Public Class ArtistsDB

Public Function GetArtists() As System.Data.DataSet

Dim strCnn As String = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=OneEarSociety;Data Source=localhost"

Dim cnn As New SqlConnection(strCnn)

Dim sqlDA As New SqlDataAdapter("SELECT ArtistID, ArtistName FROM Artists WHERE Artist='Art';", cnn)

Dim ds As New DataSet()

sqlDA.Fill(ds, "Artists")

Return ds

End Function

End Class

2)ArtistSiteMap.VB

 

Imports System

Imports System.Collections

Imports System.Collections.Specialized

Imports System.Configuration.Provider

Imports System.IO

Imports System.Security.Permissions

Imports System.Web

Namespace Samples.AspNet.VB

<AspNetHostingPermission(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _

Public Class SimpleTextSiteMapProvider

Inherits SiteMapProvider

Private parentSiteMapProvider As SiteMapProvider = Nothing

Private simpleTextProviderName As String = Nothing

Private sourceFilename As String = Nothing

Private aRootNode As SiteMapNode = Nothing

Private siteMapNodes As ArrayList = Nothing

Private childParentRelationship As ArrayList = Nothing

' A default constructor. The Name property is initialized in the

' Initialize method.

Public Sub New()

End Sub 'New

' Implement the CurrentNode property.

Public Overrides ReadOnly Property CurrentNode() As SiteMapNode

Get

Dim currentUrl As String = FindCurrentUrl()

' Build the site map in memory.

LoadSiteMapFromStore()

' Find the SiteMapNode that represents the current page.

Dim aCurrentNode As SiteMapNode = FindSiteMapNode(currentUrl)

Return aCurrentNode

End Get

End Property

' Implement the RootNode property.

Public Overrides ReadOnly Property RootNode() As SiteMapNode

Get

' Build the site map in memory and return the root SiteMapNode.

LoadSiteMapFromStore()

Return aRootNode

End Get

End Property

' Implement the ParentProvider property.

Public Overrides Property ParentProvider() As SiteMapProvider

Get

Return parentSiteMapProvider

End Get

Set(ByVal value As SiteMapProvider)

parentSiteMapProvider = value

End Set

End Property

' Implement the RootProvider property.

Public Overrides ReadOnly Property RootProvider() As SiteMapProvider

Get

' If the current instance belongs to a provider hierarchy, it

' cannot be the RootProvider. Rely on the ParentProvider.

If Not (Me.ParentProvider Is Nothing) Then

Return ParentProvider.RootProvider

' If the current instance does not have a ParentProvider, it is

' not a child in a hierarchy, and can be the RootProvider.

Else

Return Me

End If

End Get

End Property

' Implement the FindSiteMapNode method.

Public Overrides Function FindSiteMapNode(ByVal rawUrl As String) As SiteMapNode

' Does the root node match the URL?

If RootNode.Url = rawUrl Then

Return RootNode

Else

Dim candidate As SiteMapNode = Nothing

' Retrieve the SiteMapNode that matches the URL.

SyncLock Me

candidate = GetNode(siteMapNodes, rawUrl)

End SyncLock

Return candidate

End If

End Function 'FindSiteMapNode

' Implement the GetChildNodes method.

Public Overrides Function GetChildNodes(ByVal node As SiteMapNode) As SiteMapNodeCollection

Dim children As New SiteMapNodeCollection()

' Iterate through the ArrayList and find all nodes that have the specified node as a parent.

SyncLock Me

Dim i As Integer

For i = 0 To childParentRelationship.Count - 1

Dim de As DictionaryEntry = CType(childParentRelationship(i), DictionaryEntry)

Dim nodeUrl As String = CType(de.Key, String)

Dim parent As SiteMapNode = GetNode(childParentRelationship, nodeUrl)

If Not (parent Is Nothing) AndAlso node.Url = parent.Url Then

' The SiteMapNode with the Url that corresponds to nodeUrl

' is a child of the specified node. Get the SiteMapNode for

' the nodeUrl.

Dim child As SiteMapNode = FindSiteMapNode(nodeUrl)

If Not (child Is Nothing) Then

children.Add(CType(child, SiteMapNode))

Else

Throw New Exception("ArrayLists not in sync.")

End If

End If

Next i

End SyncLock

Return children

End Function 'GetChildNodes

Protected Overrides Function GetRootNodeCore() As SiteMapNode

Return RootNode

End Function ' GetRootNodeCore()

' Implement the GetParentNode method.

Public Overrides Function GetParentNode(ByVal node As SiteMapNode) As SiteMapNode

' Check the childParentRelationship table and find the parent of the current node.

' If there is no parent, the current node is the RootNode.

Dim parent As SiteMapNode = Nothing

SyncLock Me

' Get the Value of the node in childParentRelationship

parent = GetNode(childParentRelationship, node.Url)

End SyncLock

Return parent

End Function 'GetParentNode

' Implement the ProviderBase.Initialize method.

' Initialize is used to initialize the state that the Provider holds, but

' not actually build the site map.

Public Overrides Sub Initialize(ByVal name As String, ByVal attributes As NameValueCollection)

SyncLock Me

MyBase.Initialize(name, attributes)

simpleTextProviderName = name

sourceFilename = attributes("siteMapFile")

siteMapNodes = New ArrayList()

childParentRelationship = New ArrayList()

End SyncLock

End Sub 'Initialize

' Private helper methods

Private Function GetNode(ByVal list As ArrayList, ByVal url As String) As SiteMapNode

Dim i As Integer

For i = 0 To list.Count - 1

Dim item As DictionaryEntry = CType(list(i), DictionaryEntry)

If CStr(item.Key) = url Then

Return CType(item.Value, SiteMapNode)

End If

Next i

Return Nothing

End Function 'GetNode

 

' Get the URL of the currently displayed page.

Private Function FindCurrentUrl() As String

' The current HttpContext.

Dim currentContext As HttpContext = HttpContext.Current

If Not (currentContext Is Nothing) Then

Return currentContext.Request.RawUrl

Else

Return currentContext.Request.Path

End If

End Function 'FindCurrentUrl

Protected Overridable Sub LoadSiteMapFromStore()

Dim pathToOpen As String

SyncLock Me

' If a root node exists, LoadSiteMapFromStore has already

' been called, and the method can return.

If Not (aRootNode Is Nothing) Then

Return

Else

pathToOpen = HttpContext.Current.Server.MapPath("~" & "\" & sourceFilename)

If File.Exists(pathToOpen) Then

' Open the file to read from.

Dim sr As StreamReader = File.OpenText(pathToOpen)

Try

' Clear the state of the collections and aRootNode

aRootNode = Nothing

siteMapNodes.Clear()

childParentRelationship.Clear()

' Parse the file and build the site map

Dim s As String = ""

Dim nodeValues As String() = Nothing

Dim temp As SiteMapNode = Nothing

Do

s = sr.ReadLine()

If Not s Is Nothing Then

' Build the various SiteMapNode objects and add

' them to the ArrayList collections. The format used

' is: URL,TITLE,DESCRIPTION,PARENTURL

nodeValues = s.Split(","c)

temp = New SiteMapNode(Me, _

HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(0), _

HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(0), _

nodeValues(1), _

nodeValues(2))

' Is this a root node yet?

If aRootNode Is Nothing AndAlso _

(nodeValues(3) Is Nothing OrElse _

nodeValues(3) = String.Empty) Then

aRootNode = temp

' If not the root node, add the node to the various collections.

Else

siteMapNodes.Add(New DictionaryEntry(temp.Url, temp))

' The parent node has already been added to the collection.

Dim parentNode As SiteMapNode = _

FindSiteMapNode(HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(3))

If Not (parentNode Is Nothing) Then

childParentRelationship.Add(New DictionaryEntry(temp.Url, parentNode))

Else

Throw New Exception("Parent node not found for current node.")

End If

End If

End If

Loop Until s Is Nothing

Finally

sr.Close()

End Try

Else

Throw New Exception("File not found")

End If

End If

End SyncLock

Return

End Sub 'LoadSiteMapFromStore

End Class 'SimpleTextSiteMapProvider

End Namespace

3)Default.aspx

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<asp:Label ID="Label1" Runat="server" Text="Animals of Arts should always be treated with kindness and consideration."

Font-Size="Large" Width="390px" Height="54px"></asp:Label>

<br />

<asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl="~/TameAnimals.aspx">Arts And Animals</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink2" Runat="server" NavigateUrl="~/WildAnimals.aspx">Wild Animals of Arts</asp:HyperLink><br />

<br />

<asp:HyperLink ID="HyperLink3" Runat="server" NavigateUrl="~/FarmAnimals.aspx">Farm Animals of Arts</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink4" Runat="server" NavigateUrl="~/Artists.aspx">Artists</asp:HyperLink>

</form>

</body>

</html>


Arts And Animals

Wild Animals of Arts

Farm Animals of Arts

Artists

 

4)DefaultMaster

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<div>

 <table style="width: 100%; height: 100%" cellspacing="3" cellpadding="3" border="0">

<tr>

<td style="height: 18px" colspan="2">

<asp:Label ID="Label1" Runat="server" Text="Art and Animals" Font-Size="X-Large" ForeColor="SaddleBrown" BackColor="PaleGoldenrod" Font-Bold="True" BorderColor="Peru" BorderStyle="Double"></asp:Label>

</td>

</tr>

<tr>

<td style="height: 18px" align="center" colspan="2">

 </td>

</tr>

<tr>

<td style="height: 240px; width: 20%;" valign="top" bordercolor="black" bordercolordark="black">

 

</td>

<td valign=top align=left style="height: 240px; width: 500px" bordercolor="black" bordercolordark="black">

 <asp:ContentPlaceHolder ID="Default" Runat="server"></asp:ContentPlaceHolder> 

</td>

</tr>

</table>

</div><table style="width: 100%; height: 100%" cellspacing="3" cellpadding="3" border="0">

<tr>

<td style="height: 10%" colspan="2" valign="top" bordercolor="black" align="left">

</td>

</tr>

</table>

</form>

</body>

</html>

5)TamiAnimal.aspx

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<div>

<span style="font-family: Arial"><b>

<asp:Label ID="Label1" Runat="server" Text="Farm Animals of Art"></asp:Label>

 <br />

 

<br />

</b></span>

<asp:Image ID="Image1" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/Goat.jpg" />

<asp:Image ID="Image2" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/Llama.jpg" />

<asp:Image ID="Image3" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/pig.jpg"/>

</div>

</form>

</body>

</html>

 

6)FarmAnimals.aspx

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<div>

<span style="font-family: Arial"><b>

<asp:Label ID="Label1" Runat="server" Text="Farm Animals of Art"></asp:Label>

<br />

 

<br />

</b></span>

<asp:Image ID="Image1" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/Goat.jpg" />

<asp:Image ID="Image2" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/Llama.jpg" />

<asp:Image ID="Image3" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/pig.jpg"/>

</div>

</form>

</body>

</html>

6)TamiAnimals

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<div>

 <asp:Label ID="Label1" Runat="server" Text="Animals of Art">

</asp:Label> <br />

 <br />

<asp:Image ID="Image1" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/kitten.jpg" />

<asp:Image ID="Image2" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/dog.jpg" />

<asp:Image ID="Image3" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/rabbit.jpg"/> <br />

<br />

</div>

</form>

</body>

</html>

8)WildAnimals.aspx

 

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

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

<div>

<asp:Label ID="Label1" Runat="server" Height="30px" Width="366px" Text="Wild Animals of Art"></asp:Label>

<br />

<br />

<asp:Image ID="Image1" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/Giraffe.jpg" />

<asp:Image ID="Image2" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/TigerCub.jpg" />

<asp:Image ID="Image3" Runat="server" Width="118px" Height="153px" ImageUrl="~/Images/mouse.jpg"/>

</div>

</form>

</body>

</html>

9)ObjectDataSource

<%@ Page Language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

<link href="StyleSheet.css" type="text/css" rel="stylesheet" />

</head>

<body>

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

<div>

      

<asp:GridView ID="GridView1" Runat="server" DataSourceID="ObjectGenericArtists" AutoGenerateColumns="False" BorderWidth="1px" BackColor="LightGoldenrodYellow" GridLines="None" CellPadding="2" BorderColor="Tan" ForeColor="Black">

<FooterStyle BackColor="Tan"></FooterStyle>

<PagerStyle ForeColor="DarkSlateBlue" HorizontalAlign="Center" BackColor="PaleGoldenrod"></PagerStyle>

<HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>

<AlternatingRowStyle BackColor="PaleGoldenrod"></AlternatingRowStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ArtistID" DataField="ArtistID" SortExpression="ArtistID"></asp:BoundField>

<asp:BoundField ReadOnly="True" HeaderText="ArtistName" DataField="ArtistName"

SortExpression="ArtistName"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedRowStyle>

</asp:GridView>

<asp:ObjectDataSource ID="ObjectGenericArtist" Runat="server" TypeName="ArtistList"

SelectMethod="GetArtists">

</asp:ObjectDataSource><br />

 <asp:GridView ID="GridView2" Runat="server" DataSourceID="ObjectArtistDB" BorderWidth="1px" BackColor="White" GridLines="Horizontal" CellPadding="3" BorderColor="#E7E7FF" BorderStyle="None">

<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>

<PagerStyle ForeColor="#4A3C8C" HorizontalAlign="Right" BackColor="#E7E7FF"></PagerStyle>

<HeaderStyle ForeColor="#F7F7F7" Font-Bold="True" BackColor="#4A3C8C"></HeaderStyle>

<AlternatingRowStyle BackColor="#F7F7F7"></AlternatingRowStyle>

<SelectedRowStyle ForeColor="#F7F7F7" Font-Bold="True" BackColor="#738A9C"></SelectedRowStyle>

<RowStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></RowStyle>

</asp:GridView> 

<asp:ObjectDataSource ID="ObjectArtistsDB" Runat="server" SelectMethod="GetArtists"

TypeName="ArtistsDB">

</asp:ObjectDataSource>

</div>

</form>

</body>

</html>

 

9)WebCofig

<?xml version="1.0" ?>

<!-- Note: As an alternative to hand editing this file you can use the web admin tool to

configure settings for your application. Use the Website->Asp.Net Configuration option

in Visual Studio.

A full list of settings and comments can be found in machine.config.comments usually

located in \Windows\Microsft.Net\Frameworks\v2.x\Config -->

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<appSettings />

<connectionStrings>

<add name="OneEarSocietyConnection" connectionString="Server=localhost;Integrated Security=True;Database=OneEarSociety;Persist Security Info=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

<system.web>

<!-- <siteMap defaultProvider="SimpleTextSiteMapProvider">

<providers>

<add name="SimpleTextSiteMapProvider" type="Samples.AspNet.VB.SimpleTextSiteMapProvider " siteMapFile="SiteMapSource.txt"/>

</providers>

</siteMap>

-->

<!-- Set theme for entire site

<pages stylesheettheme="Tiger">

</pages>

-->

<!--

Set compilation debug="true" to insert debugging symbols into the compiled page.

Because this affects performance, set this value to true only during development.

-->

 

<compilation debug="true" />

<!--

The <authentication> section enables configuration of the security authentication

mode used by ASP.NET to identify an incoming user.

-->

<authentication mode="Windows" />

<!--

The <customErrors> section enables configuration of what to do if/when an unhandled

error occurs during the execution of a request. Specifically, it enables developers

to configure html error pages to be displayed in place of a error stack trace.

-->

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<!--

<error statusCode="403" redirect="NoAccess.htm"/>

<error statusCode="404" redirect="FileNotFound.htm"/>

-->

</customErrors>

</system.web>

</configuration>

 

10)WebSiteMapStructure.txt

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

<siteMap>

<siteMapNode url="Default.aspx" title="Home" >

<siteMapNode url="TameAnimals.aspx" title="Arts and Animals" >

<siteMapNode url="FarmAnimals.aspx" title="Farm Animals of Arts" />

</siteMapNode>

<siteMapNode url="WildAnimals.aspx" title="Wild Animals of Arts" >

<siteMapNode url="Artists.aspx" title="Artists" />

</siteMapNode>

</siteMapNode>

</siteMap>

11)SitemapSource.txt

default.aspx,Home,Art And Animals Home Page,

TameAnimals.aspx, Animals of Arts,Check Out These Great Tame Animals!,default.aspx

FarmAnimals.aspx,Farm Animals,Farm Animals of Arts Are Fiendly Too!,TameAnimals.aspx

WildAnimals.aspx,Wild Animals of Arts,Browse Our Untamed Collection!,default.aspx

Artists.aspx,Artists,Our Artists Are Truly Wild!,WildAnimals.aspx

 

 

 

 

 

 


 

 


 

 
Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”



Advertise on XMLPitstop

Advertise on XMLPitstop


EggHead Cafe
Web Servicee development
DotNetSlackers
Buy text ads here!
laptop online backup
Color Laser Printer
Diesel sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,223 Total Members
36 members(last 30 days)
8 members(last 7 days)
2 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,260 Total Blog Posts
1,839 Blogs(last 30 days)
342 Blogs(last 7 days)
49 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


 

David Silverlight's XMLPitstop.com| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139