Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir, i have a listview in which i take a radiobuttonlist. in radiobuttonlist i have 3 listitem 'P' 'A' 'L'. i need that when i select 'A' radiobutton. then the color of radiobutton is Red and when i select any other radio button then none color.i want to do it without postback.

here is my code:-

<asp:ListView ID="ListView1" runat="server" >
<layouttemplate>
XML
<td>
                                                                  <asp:Button ID="btnP" runat="server" Text="P" Font-Size=".7em" CommandName="P" Font-Bold="true"
                                                                      CausesValidation="False" Width="20px" />
                                                                  <asp:Button ID="btnA" runat="server" Text="A" Font-Size=".7em" CommandName="A" Font-Bold="true"
                                                                      CausesValidation="False" Width="20px" />
                                                                  <asp:Button ID="btnL" runat="server" Text="L" Font-Size=".7em" CommandName="L" Font-Bold="true"
                                                                      CausesValidation="False" Width="20px" />
                                                              </td>





XML
<ItemTemplate  >
                                                        <tr class="grd" onmouseout="this.style.backgroundColor=this.originalstyle;"  onmouseover="this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#65a9d7'">



XML
<td>
                                                                <asp:RadioButtonList ID="rblAttendence" SelectedValue='<%# Status(Eval("Status")) %>'
                                                                 OnTextChanged="b" onclick="a()" runat="server" RepeatLayout="Table" RepeatDirection="Horizontal"
                                                                    AutoPostBack="true" ForeColor="Red" BorderColor="#003300">
                                                                    <asp:ListItem Text="" Value="P" ></asp:ListItem>
                                                                    <asp:ListItem Text="" Value="A" ></asp:ListItem>
                                                                    <asp:ListItem Text="" Value="L" ></asp:ListItem>

                                                                </asp:RadioButtonList>
Posted
Updated 25-Feb-15 20:46pm
v2

1 solution

Refer - Attaching client-side event handler to radio button list[^].
Quote:
Anyway, what you have to do is to attach an onClick event on both of the radio buttons inside the list with a call to the same function such that you aspx code of your radio button list looks something like this:
HTML
<asp:RadioButtonList ID="rbnDetPeriod" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal" >
   <asp:ListItem Text="si" Value="SI" Selected="True" onClick="someJavaScriptFunction();" ></asp:ListItem>
   <asp:ListItem Text="no" Value="NO" onClick="someJavaScriptFunction();" ></asp:ListItem>
</asp:RadioButtonList>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900