Accessing a control's properties from a user control

Discussion in 'Microsoft VB .NET' started by RSH, Dec 18, 2006.

  1. RSH

    RSH Guest

    I have a situation where I have developed a user control that contains
    several ImageButtons with hardcoded values.

    In the codebehind I have a property that is setup to receive a string value
    from the parent page. The properties value is also the name of the control.
    So what I am trying to do, is when the property is set I want to use the
    string value to reference the appropriate imagebutton and change the
    imageurl property without having to do a large case statement.

    For example...this is one imagebutton in the ascx file:
    <asp:imagebutton id="CompanyProperty" style="LEFT: 35px; POSITION: relative;
    TOP: 7px" runat="server"
    ImageUrl="Images/companyProperty_Tab1.gif"></asp:imagebutton>


    In the control's codebehind I have the following property:
    Public Property ActiveTab() As String

    Get

    Return _ActiveTab

    End Get

    Set(ByVal Value As String)

    Dim iButton As New ImageButton

    iButton.ID = Value

    iButton.ImageUrl = "images/" & Value & ".gif"

    End Set

    End Property



    In the parent page's code I am setting the ActiveTab Property =
    "CompanyProperty"

    So what I am asking is how can I get at the CompanyProperty ImageButtutton's
    imageUrl property without having to do something like this:

    If Value="CompanyProperty" then

    end if



    Is there a way?

    Thanks so much!

    Ron
     
    RSH, Dec 18, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prateek

    Accessing Properties

    Prateek, Oct 9, 2003, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    209
    Prateek
    Oct 9, 2003
  2. alex

    accessing / setting properties

    alex, Oct 9, 2003, in forum: Microsoft VB .NET
    Replies:
    11
    Views:
    328
    Fergus Cooney
    Oct 10, 2003
  3. Mike Caputo

    Accessing form properties from another form at runtime

    Mike Caputo, Oct 27, 2003, in forum: Microsoft VB .NET
    Replies:
    8
    Views:
    238
    Fergus Cooney
    Oct 29, 2003
  4. Chris Watson

    Accessing .NET user control properties from JavaScript

    Chris Watson, Mar 13, 2004, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    739
    Chris Watson
    Mar 13, 2004
  5. Herfried K. Wagner [MVP]

    Re: Accessing File Properties

    Herfried K. Wagner [MVP], Mar 22, 2004, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    239
    Guest
    Mar 27, 2004
  6. squeaks

    accessing volume control properties

    squeaks, Oct 2, 2004, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    250
    squeaks
    Oct 2, 2004
  7. Nathan Sokalski
    Replies:
    0
    Views:
    667
    Nathan Sokalski
    Oct 17, 2005
  8. Guest
    Replies:
    0
    Views:
    581
    Guest
    Jun 8, 2006
Loading...