ASP.NET Web Controls and Accessibility (which is right?)

I wish there was a clear list of Do’s and Don’ts for web contols. It would be nice to simply look down the list of each control and make sure you have everything you need. I see so many alternative stuff online and not enough detail in each case.

Which is correct or does it matter?

Using TEXT property or placing text between tags.
<asp:LinkButton ID=“lbtnCancel” runat=“server” OnClick=“lbtnCancel_Click” Visible=“false” Text=“Cancel”></asp:LinkButton>

<asp:LinkButton ID=“lbtnCancel” runat=“server” OnClick=“lbtnCancel_Click” Visible=“false” >Cancel</asp:LinkButton>

<asp:Label ID=“lblInfoSecurity” runat=“server” AssociatedControlID=“ddlInfoSecurity” Text=“Info Security:”></asp:Label>

<asp:Label ID=“lblInfoSecurity” runat=“server” AssociatedControlID=“ddlInfoSecurity”>Info Security: </asp:Label>

I’ve seen them both and i really don’t know if it even matters or why it matters.

Thanks if you can help clear this up.

Only thing that matters is the resulting HTML, because assistive technologies don’t ever come into contact with your ASP, just as it does not come into contact with PHP templates or anything else backend. Everything goes via a browser.
If the button ends up like this
(I can’t seem to type HTML so I’m using other symbols!)
[button id=“lbtnCancel”]Cancel[/button]
and the label ends up like this
[label id=“lblInfoSecurity” for=“ddlInfoSecurity”]Info Security: [/label]
(where then the id this label is associated with matches the “for” attribute)

then you’ve done good.

As a note, if the button is in a form but is meant to be a push button (rather than a submit button, which it will be by default), add in type=“button” to it.

1 Like

Just to add Stomme_poes’ post - another thing to keep in mind is that you are always best served by using the proper semantic markup for controls. Devs often spoof controls like buttons and dropdowns because they have more control over look and feel. This is never a good idea.

Probably one of the easiest accessibility rules to remember that will have the most impact.

Thanks guys for the response. I appreciate the feedback.