If I add a user control (UC) at design time ... I have no problem reading from the controls in it ...say (text boxes) bcos I create a public property for each text box.
say in my UC i have a TextBox txtfname ...and a property p1_txtfname to read and write to it
Public Property p1_txtfname() As String
Get
Return txtfname.Text
End Get
Set(ByVal Value As String)
txtfname.Text = Value
End Set
End Property
Then in my HOST page suppose my UC id = Namebox... I can grab whatever is entered in the textbox by ....
myfNameInHostPage.Text = Namebox.p1_txtfname
..but this is bcos the UC id=Namebox is available at design time.
But suppose I add the UC dynamically at run-time like ...
Dim control As Control
control = Page.LoadControl("UserControls/Namebox.ascx")
Me.pageContentsCell.Controls.Add(control)
where pageContentsCell is say a table cell .... the page downloads OK ......
how do I read back the same
myfNameInHostPage.Text = Namebox.p1_txtfname
is it like
myfNameInHostPage.Text=control.ID("p1_txtfname") ?
since I don't know what ID will be assigned to the UC?
please help!
say in my UC i have a TextBox txtfname ...and a property p1_txtfname to read and write to it
Public Property p1_txtfname() As String
Get
Return txtfname.Text
End Get
Set(ByVal Value As String)
txtfname.Text = Value
End Set
End Property
Then in my HOST page suppose my UC id = Namebox... I can grab whatever is entered in the textbox by ....
myfNameInHostPage.Text = Namebox.p1_txtfname
..but this is bcos the UC id=Namebox is available at design time.
But suppose I add the UC dynamically at run-time like ...
Dim control As Control
control = Page.LoadControl("UserControls/Namebox.ascx")
Me.pageContentsCell.Controls.Add(control)
where pageContentsCell is say a table cell .... the page downloads OK ......
how do I read back the same
myfNameInHostPage.Text = Namebox.p1_txtfname
is it like
myfNameInHostPage.Text=control.ID("p1_txtfname") ?
since I don't know what ID will be assigned to the UC?
please help!