Cannot use ListItems when inheriting from DropDownList

N

Nathan Sokalski

I am creating a control in which I inherit from the DropDownList. The only
method that I override is RenderContents. Here is my basic code:

Public Class StatesDropDownList : Inherits DropDownList

Protected Overrides Sub RenderContents(ByVal writer As
System.Web.UI.HtmlTextWriter)
'I add several items to the Items property here using Me.Items.Add()
MyBase.RenderContents(writer)
End Sub

End Class

However, when I attempt to add ListItems declaratively (by placing
<asp:ListItem/> tags between the opening and closing tags for my control),
Visual Studio 2005 tells me "Element 'ListItem' is not a known element." I
am inheriting from DropDownList, and DropDownList works fine even in the
same Page, so shouldn't my control allow <asp:ListItem/> tags as well? Any
help would be appreciated. Thanks.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top