Results 1 to 2 of 2

Thread: User Controls, passing data

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    93

    User Controls, passing data

    I'm currently working on an ASP.NET application. I have a mainpage.aspx that contains a table control. This table control contains 4 user controls. One of the user controls (UCSearch) contains a dropdownlist that the user selects from. Depending on the selection in this dropdownlist, 1 of 2 other user controls are enabled. In the code behind for the usercontrol (UCCase) that becomes enabled I need to check the value of the dropdownlist on the UCSearch . I am having problems referencing this value. I receive an error of: Referenced object UCSearch has a value of Nothing.

    In UCCase I have:
    Private UCSearch_ As UCSearch

    And then to retreive the value:
    If UCSearch_.ddlSearchResults.Items.Count <> 0 Then

    This is the line that has the value of nothing. It seems like I'm missing saomething very simple on this but I'm unsure of what it is. Can anyone please help me out???

    Thanks,
    Corinne

  2. #2
    Addicted Member
    Join Date
    Nov 2004
    Posts
    149

    Re: User Controls, passing data

    I believe in the user control you have to have property methods to get and set the properties on the control.

    So in the user control you would have to have:

    Public Property ddlSearchResultsCount() as integer
    Get
    Return ddlSearchResults.Items.Count
    End Get
    End Property

    Then you would just call UCSearch_.ddSearchResultsCount to retrieve that value.

Posting Permissions

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



Click Here to Expand Forum to Full Width