Custom DropDownList control in ASP.NET 2.0

Discussion in 'ASP .Net' started by Steve, Mar 2, 2006.

  1. Steve

    Steve Guest

    Hi

    I've created a custom dropdown list in a web control library that my
    aspx page uses as follows:

    <%@ Register Assembly="CommonUI" Namespace="POLISY.Web.UI.Common"
    TagPrefix="cc1" %>
    ....
    <cc1:WFEDropDownList ID="WFEDropDownList1" runat="server">
    <asp:ListItem Value="A">Apple</asp:ListItem>
    <asp:ListItem Value="B">Banana</asp:ListItem>
    </cc1:WFEDropDownList></td>

    When I compile the .aspx I get the following error for each
    <asp:ListItem> within a <cc1:WFEDropDownList> element:

    Element 'ListItem' is not a known element. This can occur if there
    is a compilation error in the Web site.

    Any idea what's causing this? The code for WFEDropDownList is very
    simple. All it does is extend DropDownList as follows:


    using System.Web.UI;
    using System.Web.UI.WebControls;
    namespace POLISY.Web.UI.Common
    {
    [ToolboxData("<{0}:WFEDropDownList
    runat=server></{0}:WFEDropDownList>")]
    public class WFEDropDownList : DropDownList
    {
    // TO DO: Register javascript to display a tool tip for the
    // currently selected item in the drop down. (needed in case
    // of truncation)

    }
    }


    Thanks for your help!
    Steve, Mar 2, 2006
    #1
    1. Advertising

  2. Steve,
    You need to implement a collection in your WWE Dropdown list to hold the
    list items. http://msdn2.microsoft.com/en-us/library/9txe1d4x.aspx

    Too bad cause it seems like it would work automatically inheriting from
    dropdownlist.

    Good Luck
    DWS


    "Steve" wrote:

    > Hi
    >
    > I've created a custom dropdown list in a web control library that my
    > aspx page uses as follows:
    >
    > <%@ Register Assembly="CommonUI" Namespace="POLISY.Web.UI.Common"
    > TagPrefix="cc1" %>
    > ....
    > <cc1:WFEDropDownList ID="WFEDropDownList1" runat="server">
    > <asp:ListItem Value="A">Apple</asp:ListItem>
    > <asp:ListItem Value="B">Banana</asp:ListItem>
    > </cc1:WFEDropDownList></td>
    >
    > When I compile the .aspx I get the following error for each
    > <asp:ListItem> within a <cc1:WFEDropDownList> element:
    >
    > Element 'ListItem' is not a known element. This can occur if there
    > is a compilation error in the Web site.
    >
    > Any idea what's causing this? The code for WFEDropDownList is very
    > simple. All it does is extend DropDownList as follows:
    >
    >
    > using System.Web.UI;
    > using System.Web.UI.WebControls;
    > namespace POLISY.Web.UI.Common
    > {
    > [ToolboxData("<{0}:WFEDropDownList
    > runat=server></{0}:WFEDropDownList>")]
    > public class WFEDropDownList : DropDownList
    > {
    > // TO DO: Register javascript to display a tool tip for the
    > // currently selected item in the drop down. (needed in case
    > // of truncation)
    >
    > }
    > }
    >
    >
    > Thanks for your help!
    >
    >
    =?Utf-8?B?RFdT?=, Mar 2, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonah Olsson
    Replies:
    1
    Views:
    570
    Scott Allen
    Apr 5, 2005
  2. J R M
    Replies:
    2
    Views:
    427
    Charlie@CBFC
    Jun 1, 2006
  3. AleXmanFree
    Replies:
    3
    Views:
    566
    Hillbilly
    Oct 9, 2008
  4. Matt Sokol
    Replies:
    2
    Views:
    374
    Theo Tillotson
    Aug 7, 2003
  5. Srikar
    Replies:
    1
    Views:
    128
    Brock Allen
    Apr 19, 2005
Loading...

Share This Page