Results 1 to 4 of 4

Thread: AssociatedControlId and UserControls

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    AssociatedControlId and UserControls

    I'm new to ASP.NET and have been asked to bring our site into 508 compliance. Right now I'm working on associating labels to form fields. This seems to work well with the built in controls provided but we are also using a lot of usercontrol in our application. I can set the AssociatedControlId of the label to the usercontrol but when you run the application and click on the label it dosen't set focus on the usercontrol.

    Is there some trick to associating a label to a usercontrol?

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: AssociatedControlId and UserControls

    I doubt this cannot be done

    Because the Name suggest that

    Label.AssociatedControlID Property
    This only Can be associated with label ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: AssociatedControlId and UserControls

    By usercontrol if you mean a web user control (*.ascx), then a web user control can be a combination of other controls, so associating a label with a user control does not make sense. Similarly, for server controls, unless it's a server control that renders one single HTML element, it doesn't make sense.

    One of the tasks of 508 Compliance is to give labels a for attribute. Fair enough that you have the AssociatedControlID, but you need to understand that the AssociatedControlID will map to a server control which in turn becomes an HTML form field when it is rendered. Because a server control or user control doesn't necessarily become a form field, you need to know in advance what the ID of the form field is going to be (not the ASPX markup ID, but the rendered ID which looks something like ctl$00_blahblah_blah2).

    I don't believe that the AssociatedControlID can be assigned to the rendered ID (ClientID), and so you will probably need to do something like this

    Label1.Attributes.Add("for", TheOtherControl.ClientID)

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: AssociatedControlId and UserControls

    Make sense. Thanks.

    I will give Attributes.Add a try and see what happens.

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