用于listview中radiobuttonlist的彩色充电的Javascript [英] Javascript for color charge of radiobuttonlist in listview
问题描述
先生,我有一个列表视图,我在其中拍摄了一个radiobuttonlist。在radiobuttonlist中我有3个列表项'P''A''L'。当我选择'A'radiobutton时我需要它。那么radiobutton的颜色是红色,当我选择任何其他单选按钮然后没有颜色。我想在没有回发的情况下这样做。
这里是我的代码: -
< asp:ListView ID =ListView1runat =server>
< layouttemplate>
< td >
< asp:按钮 ID = btnP runat = server 文字 = P 字体大小 < span class =code-keyword> = 。7em CommandName = P 字体粗体 = true
< span class =code-attribute> < span class =code-attribute> CausesValidation = False 宽度 = 20px / >
< asp:按钮 ID = btnA runat < span class =code-keyword> = < span class =code-keyword> server 文本 = 字体大小 = 。7em CommandName = A Font-Bold = true
< span class =code-attribute> CausesValidation = False 宽度 = 20px / >
< < span class =code-leadattribute> asp:按钮 ID =跨度> <跨度class =code-keyword> btnL runat = 服务器 正文 = L 字体大小 = 。7em CommandName = L Font-Bold = true
< span class =code-attribute> CausesValidation = False Width = 20px / >
< / td >
< ItemTemplate > ;
< tr class = grd onmouseout = this.style.backgroundColor = this.originalstyle; < span class =code-attrib ute> onmouseover = this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = '#65a9d7' >
< td >
< asp:RadioButtonList ID = rblAttendence SelectedValue =' <% #Status(Eval( 状态))%> '
OnTextChanged = b onclick = a() runat = server RepeatLayout = 表 RepeatDirection = < span class =code-keyword>水平
< span class =code-attribute> < span class =code-attribute> AutoPostBack = true ForeColor = 红色 BorderColor = #003300 >
< asp:ListItem 文字 = 值 = P > < / asp:L istItem >
< asp:ListItem 文本 = 值 = > < / asp:ListItem >
< asp:ListItem 文字 = 值 = L > < / asp:ListItem >
< / asp:RadioButtonList >
参考 - 将客户端事件处理程序附加到单选按钮列表 [ ^ ]。
引用:Anyw ay,你要做的是在列表中的两个单选按钮上附加一个onClick事件,调用相同的函数,这样你的单选按钮列表的aspx代码看起来像这样:
< asp:RadioButtonList ID = rbnDetPeriod runat = < span class =code-keyword> server RepeatLayout = 流程 RepeatDirection = 水平 >
< asp:ListItem 文本 = si 值 = SI 已选择 = True onClick = someJavaScriptFunction(); > < / asp:ListItem >
< asp:ListItem 文本 = no 值 = NO onClick = someJavaScriptFunction(); > < / asp:ListItem >
< / asp:RadioButtonList >
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>
<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>
<ItemTemplate >
<tr class="grd" onmouseout="this.style.backgroundColor=this.originalstyle;" onmouseover="this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#65a9d7'">
<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>
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:
<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>
这篇关于用于listview中radiobuttonlist的彩色充电的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!