Control. What am I doing wrong?

S

shapper

Hello,

I am creating a class with a control. I compiled the class and used it
on an Asp.Net 2.0 web site page.
I can see the begin and end tags of my control (<ol> and </ol>) but
somehow the child controls (just a literal for testing) of my control
is not being added to the page.

Could someone tell me what am I doing wrong?

' List
<DefaultProperty("ID"), ToolboxData("<{0}:List runat=server></
{0}:List>")> _
Public Class List
Inherits WebControl
Implements INamingContainer

Public Sub New()
End Sub ' New


Protected Overrides Sub CreateChildControls()

Dim l As New Literal
l.Text = "<li>" & Me.Items.Count & "</li>"
MyBase.Controls.Add(l)

' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True

End Sub ' CreateChildControls

' RenderBeginTag
Public Overloads Overrides Sub RenderBeginTag(ByVal writer As
HtmlTextWriter)

' Add control attributes
With writer
If Not String.IsNullOrEmpty(Me.ID)
Then .AddAttribute(HtmlTextWriterAttribute.Id, Me.ClientID)
If Not String.IsNullOrEmpty(Me.CssClass)
Then .AddAttribute(HtmlTextWriterAttribute.Class, Me.CssClass)
End With ' writer

' Render begin tag
writer.RenderBeginTag(HtmlTextWriterTag.Ol)

End Sub ' RenderBeginTag

' RenderEndTag
Public Overloads Overrides Sub RenderEndTag(ByVal writer As
HtmlTextWriter)

' Render end tag
writer.RenderEndTag()

End Sub ' RenderEndTag

End Class ' List

Could someone tell me what am I doing wrong?

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top