Click here to Skip to main content
15,893,487 members
Articles / Web Development / ASP.NET

Page Template Framework for ASP.NET 1.1

Rate me:
Please Sign up or sign in to vote.
4.64/5 (63 votes)
16 Nov 20048 min read 298.2K   5.3K   168  
The Page Template Framework for ASP.NET 1.1 provides a configurable solution for creating page templates in a Web application. Using this framework, page templates are stored in an XML file, and can be dynamically configured without recompiling the Web application.
Imports System
Imports System.Collections
Imports System.Xml.Serialization

Namespace Config

    ' Represents the Pages which use the Page Templates in the PageConfig
    <XmlRoot("Pages")> _
    Public Class PageCollection
        Inherits System.Collections.CollectionBase

        ' The default Page Template to be used by Pages that implement the 
        ' PageBase class,  but are not registered individually
        <XmlAttributeAttribute()> _
        Public DefaultTemplateName As String

        ' Indexer that will return the Page at the specified index
        <XmlArrayItem("Page")> _
        Default Public Property Item(ByVal index As Int32) As Page

            Get

                ' Return the Page from the internal IList at the specified index
                Return CType(Me.List.Item(index), Page)

            End Get

            Set(ByVal Value As Page)

                ' Store the specified Page in the internal IList
                Me.List.Item(index) = Value

            End Set

        End Property


        ' Method that will Add a Page to the PageCollection
        ' @page: The Page to add to the PageCollection
        Public Sub Add(ByVal page As Page)

            ' Add the specified Page to the internal IList
            Me.List.Add(page)

        End Sub

        ' Method that will insert the specified Page to the PageCollection at 
        ' the specified index
        ' @index: The index at which to Page should be inserted
        ' @page: The Page to insert into the PageCollection
        Public Sub Insert(ByVal index As Int32, ByVal page As Page)

            ' Insert the specified Page to the internal IList
            Me.List.Insert(index, page)

        End Sub

        ' Method that will remove the specified Page from the PageCollection
        ' @page: The Page to be removed from the PageCollection
        Public Sub Remove(ByVal page As Page)

            ' Remove the page from the internal IList
            Me.List.Remove(page)

        End Sub

        ' Method that will return the index of the specified Page in the PageCollection
        ' @page: The Page whose index is being requested
        ' returns: The index of the specified Page in the PageCollection
        Public Function IndexOf(ByVal page As Page) As Int32

            ' Obtain the index of the Page from the interal IList
            Return Me.List.IndexOf(page)

        End Function

        ' Method that will determine if the specified Page exists in the PageCollection
        ' @page: The Page to be located
        'returns: A boolean value indicated whether or not the PageCollection contains the specified Page
        Public Function Contains(ByVal page As Page) As Boolean

            ' Check to see if the Page exists in the internal IList
            Return Me.List.Contains(page)

        End Function

    End Class

End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Scott Van Vliet is a Principal Consultant with Neudesic based in Irvine, CA. He has been designing and developing technology solutions for the past 8 years, and has worked with Microsoft .NET technologies for over 3 years. Scott is currently developing solutions with ASP.NET 2.0, C# 2.0, Windows Presentation Foundation (codename "Avalon"), SQL Server 2000/2005, Reporting Services and SharePoint.

Scott welcomes feedback and can be reached through his Weblog at http://weblogs.asp.net/skillet/.

Comments and Discussions