473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Cannot use ListItems when inheriting from DropDownList

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.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Oct 17 '08 #1
1 1625
Hi, Nathan.

You need to specify a ControlBuilder.

http://msdn.microsoft.com/en-us/libr...r(VS.85)..aspx

The ControlBuilder object must know how to create the items.

Regards,

Paulo Santos
http://pjondevelopment.50webs.com

On Oct 16, 9:36*pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
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.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
Oct 17 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Doug | last post by:
I want to display a drop-down list (System.Web.UI.WebControls.DropDownList) loaded with font names the user can select (Verdana, Garamond, etc)... got this far no problem. Now I'd like to have...
1
by: Jeff | last post by:
Hi - I'm creating a web control library (using VB.NET), and I'm trying to add a modified asp:dropdownlist control to it. How do I add asp:ListItems to the dropdownlist (within the web control...
1
by: HoustonFreeways | last post by:
I am populating a dropdownlist via a databind to a database. However, the text to be displayed can be very long, making the dropdownlist very wide. I need some way to reduce the width of the...
2
by: Arthur Dent | last post by:
Hi all, I have a control which i wrote which inherits the asp:dropdownlist control. Works great, all happy. If when using it i try to declaratively add some items, it complains that they are...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
8
by: sudhaMurugesan | last post by:
Hi, Can anyone Help. I have two dropdownlist for qualification and degree. According to the qualification(eg.Diploma,UG,PG) degree gets binded in the dropdownlist. I have done this in...
25
by: sudhaMurugesan | last post by:
Hi ALL, I am binding ListItems to dropdownlist using js.But the selected value is not retained while save operation. Do I need to capture the selected Item in any hiddenfields ? plz tell me ...
0
by: Radu | last post by:
I have a global resource, Scorecards.resx. For stuff like <asp:CustomValidator id="validDate" Text="*" ErrorMessage= "<%$ Resources:Scorecards, String66 %>" Display="Dynamic"...
1
by: Nathan Sokalski | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.