Click here to Skip to main content
15,886,806 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 297.7K   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 Page Templates available within the PageConfig
    <XmlRoot("PageTemplates")> _
    Public Class PageTemplateCollection
        Inherits System.Collections.CollectionBase

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

            Get

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

            End Get

            Set(ByVal Value As PageTemplate)

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

            End Set

        End Property


        ' Method that will Add a PageTemplate to the PageTemplateCollection
        ' @page: The PageTemplate to add to the PageTemplateCollection
        Public Sub Add(ByVal pageTemplate As PageTemplate)

            ' Add the specified PageTemplate to the internal IList
            Me.List.Add(pageTemplate)

        End Sub

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

            ' Insert the specified PageTemplate to the internal IList
            Me.List.Insert(index, pageTemplate)

        End Sub

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

            ' Remove the PageTemplate from the internal IList
            Me.List.Remove(pageTemplate)

        End Sub

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

            ' Obtain the index of the PageTemplate from the interal IList
            Return Me.List.IndexOf(pageTemplate)

        End Function

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

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

        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