473,397 Members | 1,961 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,397 software developers and data experts.

Using Custom DropDownList in UserControl

Joe
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,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Dec 20 '05 #1
1 2548
Joe
Never mind. Found a workaround.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Joe" wrote:
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,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Dec 20 '05 #2

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

Similar topics

3
by: Todd Schinell | last post by:
Back in July, Jeffery Tan posted this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl In response as to how to get click events from a...
1
by: VB Programmer | last post by:
I have a usercontrol that contains a dropdownlist that is populated dynamically from a database (Page_Load of usercontrol). How long will the uc "retain" the "life" of that dropdownlist if no...
5
by: Dag | last post by:
Hi all, I have a project where we use lots of user controls. We would like to move them to private assemblied custom controls but from what I see this can't be done because the .ascx file must...
0
by: RyanG | last post by:
when the value that determines the filter is databound?? I am trying to make a DropDownList for a set of data that I use a lot throughout my project. So I extended the DropDownList to retrieve...
1
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
2
by: OJ | last post by:
Hi, ASP.NET C# 2.0 I have a usercontrol which contains a Gridview. I create my own DataTable to bind to the GridView, which then fires the RowDataBound event of the the Gridview. Here I add a...
5
by: Mukesh | last post by:
Hi i want to use AJAX.net in my Existing Application I have already installed the ajax .net ..net 3.0 and using VS 2005 in the old application i have added a new web form then script manager...
0
by: stevem2112 | last post by:
I have a datagrid with 2 Template columns. One column has DropDownLists and the other has Textboxes. I bind each DDL in the ItemCreated event. This datagrid is inside a UserControl that is inside...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.