"Nick Stansbury" <> wrote in message
news:...
> Hi,
> Apologies for what are probably pretty basic questions - and my
convoluted
> explanation. Built some simple user controls, that represent the UI side
for
> a whole bunch of Event objects (in the form of real everyday events likes
> conferences, seminars etc.). So I have the following:
>
> Class EventBase
> EventTitle as string
> etc.
> End Class
> Class EventSummary : Inherits EventBase
> EventDate as dataTime
> etc.
> End Class
> class EventDetails : Inherits EventBase
> LongDescription as string
> End class
>
> And user controls CtlEventSummary.ascx & CtlEventDetail.ascx , each of
> which have a BoundEvent as EventBase property and a BindEventDetails
Method.
> Seemed like a great idea, until I ran into some pretty simple problems:
>
> I tried to go (summary):
>
> For each CurrentEvent as EventBase in Session("CurrentEventList") 'stored
> list of events to be displayed
> 'for a summary object
> CurrentControl = new CtlEventSummary
> CurrentControl.EventTitle = CurrentEvent.EventTitle
> 'etc.
> PlaceHolderEventList.Controls.Add(CurrentControl)
> CurrentControl.BindEventDetails() 'which basically does this :
> Me.LblEventTitle = Me.EventTitle
> '...
> next
You need to use LoadControl to load a user control. This is because the HTML
in the user control needs to be compiled. In particular, "CtlEventSummary"
is just the codebehind. There is a generated class, something like
ASP._CtlEventSummary, which inherits from CtlEventSummary, and which is only
created when the user control is compiled. LoadControl will ensure that this
happens.
--
John Saunders
johnwsaundersiii at hotmail
|