Referencing controls on user controls

J

Jim Corey

Hello,

I have common dropdowns on several user controls, and so I'm trying to get
of repetitive code.
The dropdowns allow me to pick months, days, etc.

I've put a dropdown on a usercontrol that I call DatePick, which shows up in
the code-behind as:
Protected WithEvents StartMonth As
System.Web.UI.WebControls.DropDownList

In the page_load event of a parent control I have:
Dim myDatePick As DatePick
myDatePick = CType(Me.Controls(0), DatePick)

and this allows me to access any public properties of DatePick.
But I can't get the selecteditem.text from StartMonth.

If I change StartMonth to 'Friend' rather than 'Protected' then I can
reference it as
myDatePick.StartMonth, and it compiles, but I get an error when it runs.

Should I be able to retrieve the selecteditem.text of StartMonth in my
parent control?
(I don't think I want to deal with events of StartMonth).

TIA,
Jim
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top