Last post Feb 08, 2018 02:02 PM by aazizasp
Jan 31, 2018 06:03 PM|aazizasp|LINK
I have a grid view that has several columns and two radio buttons. The radio buttons text property is empty because I rely on the column header of the grid view. Our accessibility manager ran her scans and returned to me with several issues. She said that
the radio buttons need a label. Also she provided me with the error message. "Form elements do not have associated labels." This was the issue and the elements in questions were the radio buttons.
I told her that I cannot add a label to the radio buttons without displaying the the text in each and every cell of the radio buttons. I do not want to display any text around the radio buttons. She mentioned some attributes like aria-label and other aria
attributes but when I researched them, most of the controls they work with are not asp.net controls.
I tried adding a label after the radio button in template in the grid view and set its display:none but the audit came back with same issues. "Form elements do not have associated labels."
Any ideas how I can solve this?
Feb 04, 2018 03:48 PM|Eric Du|LINK
According to your description, i know your needs in general, you say you add label after the radiobutton, but you want it invisible. i notice that you set it display attribute to none, as far as i know, display:none will make this element disappear in the
page, that meaning is you can not notice it and find it in the page. So i hope you could try set it
visibility:hidden, it meaning is you could find it, but you can't see it.
Also if you still can not solve the issue, please post your code and detailed needs description.
Feb 08, 2018 02:02 PM|aazizasp|LINK
so the radio buttons are inside a template fields and I tried your suggestion and ran the audit and it came back with the same issue.
<asp:RadioButton ID="r1" runat="server" Checked='<%# bool.Parse(Eval("Yes").ToString() == "Y" ? "True": "False") %>' GroupName="YesNo" />
<label for"r1" style="visibility:hidden">Yes Radio Button</label>
Here is what I get when I run the audit on this page:
Form elements do not have associated labels.
<input id="Gridview1_r1_0" type="radio" name="Gridview1$ctl02$YesNo" value="r1">
<input id="Gridview1_r2_0" type="radio" name="Gridview1$ctl02$YesNo" value="r2">
<input id="Gridview1_r1_1" type="radio" name="Gridview1$ctl03$YesNo" value="r1">
<input id="Gridview1_r2_1" type="radio" name="Gridview1$ctl03$YesNo" value="r2">