Client Side Labels with Section 508 and ASP.NET 1.1

Note: Please refer to my updated post on the subject if you have .NET 1.1 SP1.

I've been looking into making some of my ASP.NET code more accessible in ASP.NET 1.1 through Section 508 compliance.  I thought I would share on small nugget that I came up with.

I ned a <label> to be output to the browser.  An <asp:label> control won't do because it outputs to a <span>, I think, on the client.  As a result, I added the attribute runat="server" to my <label> control and I gave it an id="lbl508Control" value.  I can specify the control in the list of controls in the codebehind file like this

Protected WithEvents lbl508Control As System.Web.UI.HtmlControls.HtmlGenericControl

The last step is to add this piece of code into your page load event to associate the label control with the control to be described.

lbl508Control.Attributes.Add("for", AssociatedControl.ClientID)

Just using the ID of the associated control won't work as you need to the client side associated control.

If anyone has any suggestions, please feel free to add them in as feedback.  I look forward to reading them.

Wally

PS.  Thanks to Paul Murphy, Ryan Trudell Schwartz, and Chris Frazier for suggestions @ aspadvice.

1 Comment

Comments have been disabled for this content.