I'm trying to create my own drop down list to use on a web page and I just can't get it to work the way I need want.
In it's most basic form I can create a class, inherit from System.Web.UI.WebControls.DropDownList, register it on the page, add the markup and it will at least show a control on the page:
My Class:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace CustomDropdown
<DefaultProperty("Text"), ToolboxData("<{0}:DropDownListWithAttributes runat=server></{0}:DropDownListWithAttributes>")>
Public Class DropDownListWithAttributes
Inherits System.Web.UI.WebControls.DropDownList
End Class
End Namespace
Page Register:
<%@ Register TagPrefix="myControls" Namespace="CustomDropdown" %>
Markup:
<myControls:DropDownListWithAttributes ID="ddlMyTestCustomDDL" runat="server"></myControls:DropDownListWithAttributes>
But that's it. That's as far as I can get. I cannot access it from code behind at all. It's like it doesn't exist. I need to be able to fill it with items, trigger events, etc... All the things a normal drop down list would be able to do.
The markup seems to think it can have events:

But when I add one the designer breaks:

So I do not get normal ddl functionality, I'm unable to access the control from code behind, adding any kind of event breaks stuff...I'm at a loss on how to make this work :(



<Assembly: TagPrefix("CustomDropdown", "myControls")>before theNamespace CustomDropdowndeclaration. It would also needImports System.Security.Permissionsand the attributesAspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)in addition to theToolboxDataattribute.