Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing value of a child control from host page

    Hello,

    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

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    47
    Thanks
    2
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •