View Full Version : Changing value of a child control from host page

03-14-2007, 12:20 AM

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

End If
End Sub

Thanks for any help.

Steve Manning

03-15-2007, 04:24 PM
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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum