|
-
Sep 16th, 2008, 07:45 AM
#1
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?
-
Sep 16th, 2008, 08:33 AM
#2
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
-
Sep 17th, 2008, 12:22 PM
#3
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)
-
Sep 18th, 2008, 07:28 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|