To add image in RadioButtonList (Static) control
<asp:RadioButtonList ID="rblEmployee" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" Width="512px"> <asp:ListItem Value="Kevin"><span style="vertical-align:40px;">Kevin</span> <img width=100px src=images/Kevin.jpg></asp:ListItem> <asp:ListItem Value="Corne"><span style="vertical-align:40px;">Corne</span> <img width=100px src=images/Corne.jpg></asp:ListItem> <asp:ListItem Value="Paul"><span style="vertical-align:40px;">Paul</span> <img width=100px src=images/Paul.jpg></asp:ListItem> </asp:RadioButtonList>
Use below script to align Image and Radiobutton Alignment
<style type="text/css"> .ListControl input[type=checkbox], input[type=radio] { display: none3; Vertical-align: 40px; } </style>
Required Filed Validation for RadioButtonList
<asp:RequiredFieldValidator ID="rfvEmployee" runat="server" ControlToValidate="rblEmployee" ErrorMessage="Please Select Employee"></asp:RequiredFieldValidator>
Submit Button Event to get RadioButtonList Selected Text
protected void btnSubmit_Click(object sender, EventArgs e) { lblMessage.Text = "Selected Employee ::: " + rblEmployee.SelectedItem.Value; }
Output:
Validation: