R
randman
I have created an ASPX page that has a placeholder that dynamically gets
assigned various user controls (that I have also created) during runtime. On
one of the user controls contains a textbox. I need to access the ascx page
textbox value from a sub routine in the aspx page.
This is the code that I have that returns the value of the textbox (named
txtName)
Public Property UserName() As String
Get
Return txtName.Text
End Get
Set(ByVal Value As String)
txtName.Text = Value.ToString
End Set
End Property
When I call this from my aspx page nothing is returned even though I have
typed something into the txtName textbox.
If I assign a value to the textbox, as in the following example, then the
value ("Hello") does appear in the aspx page that calls this code.
Public Property UserName() As String
Get
txtName.Text = "Hello"
Return txtName.Text
End Get
Set(ByVal Value As String)
txtName.Text = Value.ToString
End Set
End Property
The user control is called ranman.ascx
This is the code that dynamically assigns the user control to the aspx page
Session("strBody") = ranman
strControlBody = "controls\" & CStr(Session("strBody")) & ".ascx"
ctlBody = LoadControl(strControlBody)
phBody.Controls.Add(ctlBody)
This is the code on the aspx page that calls the user control
Dim myUserControl As ranman = CType(LoadControl("controls\ranman.ascx"),
ranman)
strUserName = myUserControl.UserName
It seems like a timing issue, but I could be wrong
I'm not even sure if I am on the right path with this. Please help !!
Thanks in advance,
Randman
assigned various user controls (that I have also created) during runtime. On
one of the user controls contains a textbox. I need to access the ascx page
textbox value from a sub routine in the aspx page.
This is the code that I have that returns the value of the textbox (named
txtName)
Public Property UserName() As String
Get
Return txtName.Text
End Get
Set(ByVal Value As String)
txtName.Text = Value.ToString
End Set
End Property
When I call this from my aspx page nothing is returned even though I have
typed something into the txtName textbox.
If I assign a value to the textbox, as in the following example, then the
value ("Hello") does appear in the aspx page that calls this code.
Public Property UserName() As String
Get
txtName.Text = "Hello"
Return txtName.Text
End Get
Set(ByVal Value As String)
txtName.Text = Value.ToString
End Set
End Property
The user control is called ranman.ascx
This is the code that dynamically assigns the user control to the aspx page
Session("strBody") = ranman
strControlBody = "controls\" & CStr(Session("strBody")) & ".ascx"
ctlBody = LoadControl(strControlBody)
phBody.Controls.Add(ctlBody)
This is the code on the aspx page that calls the user control
Dim myUserControl As ranman = CType(LoadControl("controls\ranman.ascx"),
ranman)
strUserName = myUserControl.UserName
It seems like a timing issue, but I could be wrong
I'm not even sure if I am on the right path with this. Please help !!
Thanks in advance,
Randman