Legen Sie eine CSS-Klasse für ein ASP.NET RadioButtonList ListItem fest
Gibt es eine Möglichkeit, eine CSS-Klasse für ein Eingabeelement in einer Optionsfeldliste festzulegen? Ich möchte diese Formularwerte nach Klasse in jQuery referenzieren.
Gegeben eine ASP.NET RadioButtonList mit Klassen für die ListItems:
<asp:RadioButtonList ID="RadioButtonList" runat="server">
<asp:ListItem class="myClass" Text="Yes" Value="1" />
<asp:ListItem class="myClass" Text="No" Value="0" />
</asp:RadioButtonList>
Wird gerendert als:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span class="myClass">
<input id="RadioButtonList_0" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span class="myClass">
<input id="RadioButtonList_1" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
Leider wurde die Klasse "myClass" zur Klasse hinzugefügt<span>
das enthält das Optionsfeld Element, nicht die<input>
selbst. Wie könnte ich es stattdessen so aussehen lassen:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span>
<input id="RadioButtonList_0" class="myClass" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span>
<input id="RadioButtonList_1" class="myClass" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
(Dies betrifft nicht einmal das Hinzufügen von Klassen zu dynamisch gebundenen RadioButtonLists.)