Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-13-2007, 11:20 PM #1
- Join Date
- Jan 2004
- Thanked 0 Times in 0 Posts
Changing value of a child control from host page
I'm fairly new to .Net. I have spent quite a bit of time on this problem and am stumped. How does the host page reach controls that are inside user controls?
In the code below, "txtPCPName" is on the front page, but "txtAttendingName" is a child control of a web user control I created. I want to take the value of txtPCPName and assign it to txtAttendingName.
Private Sub checkPrimarySame_ServerChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkPrimarySame.ServerChange
If checkPrimarySame.Checked = True Then
txtPCPName.Text = txtAttendingName.Text
Thanks for any help.
03-15-2007, 03:24 PM #2
- Join Date
- Nov 2006
- Thanked 1 Time in 1 Post
What error are you getting? It could be that you need to add a protected withevents statement to youe declarations section:
Protected WithEvents txtAttendingName As System.Web.UI.WebControls.TextBox
or, it could be that you are trying to access a client control from the server. When a control is nested in another asp.net adds additional info to the id of the control. There are ways to still access it though. Let me know the error and I can tell you more information.