Results 1 to 4 of 4

Thread: TemplateControl & ITemplate

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Question TemplateControl & ITemplate

    I am making a Pagable Repeater Control becaus I just don't like the excel/access datagrid layout and I want to be able to page a custom view.

    Here is what I have.
    VB Code:
    1. Imports System.ComponentModel
    2. Imports System.Data
    3. Imports System.Web
    4. Imports System.Web.UI
    5.  
    6. <ParseChildren(True), _
    7. ToolboxData("<{0}:CustomPager runat=server></{0}:CustomPager>")> _
    8. Public Class CustomPager : Inherits TemplateControl
    9.     Private Class RepeaterItem : Inherits Control : Implements INamingContainer
    10.         Private _ItemIndex As Integer
    11.         Private _DataItem As Object
    12.  
    13.         Public Sub New(ByVal ItemIndex As Integer, ByVal DataItem As Object)
    14.             MyBase.New()
    15.             _ItemIndex = ItemIndex
    16.             _DataItem = DataItem
    17.         End Sub
    18.         Public ReadOnly Property DataItem() As Object
    19.             Get
    20.                 Return _DataItem
    21.             End Get
    22.         End Property
    23.         Public ReadOnly Property ItemIndex() As Integer
    24.             Get
    25.                 Return _ItemIndex
    26.             End Get
    27.         End Property
    28.     End Class
    29.  
    30.     Private _AlternatingItemTemplate As ITemplate = Nothing
    31.     <TemplateContainer(GetType(RepeaterItem))> Public Property AlternatingItemTemplate() As ITemplate
    32.         Get
    33.             Return _AlternatingItemTemplate
    34.         End Get
    35.         Set(ByVal Value As ITemplate)
    36.             _AlternatingItemTemplate = Value
    37.         End Set
    38.     End Property
    39.     Private _ItemTemplate As ITemplate = Nothing
    40.     <TemplateContainer(GetType(RepeaterItem))> Public Property ItemTemplate() As ITemplate
    41.         Get
    42.             Return _ItemTemplate
    43.         End Get
    44.         Set(ByVal Value As ITemplate)
    45.             _ItemTemplate = Value
    46.         End Set
    47.     End Property
    48.     Private _FooterTemplate As ITemplate = Nothing
    49.     <TemplateContainer(GetType(RepeaterItem))> Public Property FooterTemplate() As ITemplate
    50.         Get
    51.             Return _FooterTemplate
    52.         End Get
    53.         Set(ByVal Value As ITemplate)
    54.             _FooterTemplate = Value
    55.         End Set
    56.     End Property
    57.     Private _HeaderTemplate As ITemplate = Nothing
    58.     <TemplateContainer(GetType(RepeaterItem))> Public Property HeaderTemplate() As ITemplate
    59.         Get
    60.             Return _HeaderTemplate
    61.         End Get
    62.         Set(ByVal Value As ITemplate)
    63.             _HeaderTemplate = Value
    64.         End Set
    65.     End Property
    66.     Private _DataSource As WebControls.BaseDataList = Nothing
    67.     Public Property DataSource() As WebControls.BaseDataList
    68.         Get
    69.             Return _DataSource
    70.         End Get
    71.         Set(ByVal Value As WebControls.BaseDataList)
    72.             _DataSource = Value
    73.         End Set
    74.     End Property
    75.  
    76.  
    77.     Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
    78.     End Sub
    79.     Protected Overrides Sub CreateChildControls()
    80.  
    81.     End Sub
    82.     Protected Overrides Sub OnDataBinding(ByVal e As System.EventArgs)
    83.  
    84.     End Sub
    85.  
    86. End Class

    What I am Curious about is when you use an <asp:Repeater> you get intell sense on <ItemTemplate> and so on and vs.net doesn't whine about tags being undefined. My class does not work like that and vs.net does whine. Does that mean my control won't work like a repeater?

    I am just curious because I want to fix it know before I write all the loopy logic and data handling to draw out the templates. Is there one already because this is going to be allot of code for something that is already there.

    Thanks for any insight, ideas and oh I wrote one alreadys.
    Magiaus

    If I helped give me some points.

  2. #2

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Nobody has ever made a template control?
    Magiaus

    If I helped give me some points.

  3. #3
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    unfortunately, no.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  4. #4

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I think you mean fortunatly.... it's slightly confusing. I mean if it was documented maybe it wouldn't be, but hey who needs more then one printed page or two of documetation anyway.
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width