Using Custom DropDownList in UserControl

G

Guest

Hello All:

I have created a class (UpdatedDropDown) that inherits from DropDownList and
I have included the following code in this class:

Public Class UpdatedDropDown
Inherits DropDownList

Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
For c As Integer = 0 To Items.Count - 1
Dim li As ListItem = Items(c)
writer.WriteBeginTag("option")
If li.Selected Then
writer.WriteAttribute("selected", "selected", False)
End If
writer.WriteAttribute("value", li.Value, True)
Dim AttrEnum As System.Collections.IEnumerator =
Items(c).Attributes.Keys.GetEnumerator
Do While AttrEnum.MoveNext
writer.WriteAttribute(CType(AttrEnum.Current, String),
CType(AttrEnum.Current, String))
Loop
writer.Write(">")
System.Web.HttpUtility.HtmlEncode(li.Text, writer)
writer.WriteEndTag("option")
writer.WriteLine()
Next
End Sub
End Class

I am doing this so that I can render the style attribute in the ListItems
contained in the DropDownList.

I now want to use this control in a UserControl called
AugmentedDropDownList. Here is the HTML markup for the UserControl:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="AugmentedDropDownList.ascx.vb"
Inherits="WBMI.Claims.AugmentedDropDownList"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="UDD" TagName="UpdatedDropDown"
src="../Classes/UpdatedDropDown.vb"%>
<TABLE class="interior" id="Table1" width="100%">
<TR>
<TD width="150" class="tabledata"><asp:label id="Label1"
runat="server"></asp:label></TD>
<TD class="tabledata"><UDD:UpdatedDropDown id="DropDownList1"
runat="server"></UDD:UpdatedDropDown></TD>
</TR>
</TABLE>

UpdatedDropDownList is contained in a directory called Classes and
AugmentedDropDownList is located in a directory called UserControls. These
two directories are "sibling' directories (they are on the same level within
the file system tree structure).

This is not working, probably because I'm not sure what I'm doing. Can
anyone help me figure out why, when I 'View Design' on the UserControl, I see
that there was an error creating the controls in AugmentedDropDownList?

TIA,
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top