Referencing controls on user controls

  • Thread starter Thread starter Jim Corey
  • Start date Start date
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
 
Back
Top