Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: template


Message #1 by "DT-Rene Vazquez" <renevazquez@c...> on Tue, 17 Dec 2002 14:53:51 -0500
I think the hard part is of getting the form-controls of every page in a 
specific region in your basepage. For this, I've written an example which 
might be usefull to you as well.. This example places the form content in 
a table-container.

Arjen O.


Public Class BasePage : Inherits System.Web.UI.Page

    ' Stores all the controls specified as nested tags.
    Private items As New ArrayList()

    ' This function is internally invoked by 
IParserAccessor.AddParsedSubObject(Object).
    Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
        items.Add(obj)
        MyBase.AddParsedSubObject(obj)
    End Sub

    ' This function creates all child controls
    Protected Overrides Sub CreateChildControls()
        Dim myEnumerator As System.Collections.IEnumerator = 
items.GetEnumerator()
        While myEnumerator.MoveNext
            If TypeOf (myEnumerator.Current) Is HtmlForm Then
                Me.Controls.Add(HtmlFormContainer(myEnumerator.Current))
            Else
                Me.Controls.Add(myEnumerator.Current)
            End If
        End While
    End Sub

    ' This function expects a htmlform as parameter and places it in a 
specific containerControl
    Public Overridable Function HtmlFormContainer(ByVal contents As 
HtmlForm) As Web.UI.Control
        Dim myTable As New Table() : Dim myRow As New TableRow() : Dim 
myCell As New TableCell()
        myRow.Cells.Add(myCell) : myTable.Rows.Add(myRow)
        myTable.BorderStyle = BorderStyle.Solid : myTable.BorderWidth = 
New Unit(2)
        myCell.Controls.Add(contents) ' Add contents to cell
        Return myTable
    End Function

    ' Constructor
    Public Sub New()
        MyBase.New()
    End Sub

End Class



  Return to Index