K
Kees de Winter
Hi,
I dynamically create several user controls of the same type but then on
postback I can not access the properties of the user controls. Why is that??
I get the "Object reference not set to an instance of an object. ".
Here is how I create the user controls:
For intRoom As Integer = 0 To totalRooms - 1
Dim myUC As Control = Page.LoadControl("Entry_Guestnames.ascx")
CType(myUC, Entry_Guestnames).roomNo = intRoom
CType(myUC, Entry_Guestnames).totalAdults = intAdultsInRoom
myUC.ID = "UC_ID_" + intRoom.ToString
PlaceHolder1.Controls.Add(myUC)
Next
On postback I try to access a property Firstname.
Dim uc As New Entry_Guestnames
uc = CType(FindControl("UC_ID_0"), Entry_Guestnames)
Response.Write(uc.FirstName)
The last line gives me the error. What am I doing wrong?
Thanks,
Kees de Winter
I dynamically create several user controls of the same type but then on
postback I can not access the properties of the user controls. Why is that??
I get the "Object reference not set to an instance of an object. ".
Here is how I create the user controls:
For intRoom As Integer = 0 To totalRooms - 1
Dim myUC As Control = Page.LoadControl("Entry_Guestnames.ascx")
CType(myUC, Entry_Guestnames).roomNo = intRoom
CType(myUC, Entry_Guestnames).totalAdults = intAdultsInRoom
myUC.ID = "UC_ID_" + intRoom.ToString
PlaceHolder1.Controls.Add(myUC)
Next
On postback I try to access a property Firstname.
Dim uc As New Entry_Guestnames
uc = CType(FindControl("UC_ID_0"), Entry_Guestnames)
Response.Write(uc.FirstName)
The last line gives me the error. What am I doing wrong?
Thanks,
Kees de Winter