N
Nick Stansbury
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
But I am getting an object not set error - because the Labels in the custom
control haven't been initialised yet. I could use the LoadControl() method -
but I don't really understand what it does or what I should have to use it.
In addition can someone help me out with how I deal with @Register
directives when I am using code-behind for all pages? If I end up having to
use LoadControl() how do I register the user control on the .vb page? Do I
need to?
Many thanks
Nick Stansbury
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
But I am getting an object not set error - because the Labels in the custom
control haven't been initialised yet. I could use the LoadControl() method -
but I don't really understand what it does or what I should have to use it.
In addition can someone help me out with how I deal with @Register
directives when I am using code-behind for all pages? If I end up having to
use LoadControl() how do I register the user control on the .vb page? Do I
need to?
Many thanks
Nick Stansbury