20
<asp:RadioButtonList ID="rdStatus" onclick="javacript:display();" runat="server" RepeatDirection="Vertical">
<asp:ListItem Text="Temporary Waiver" Value="T" Selected="True"></asp:ListItem>    
<asp:ListItem Text="Never Expires" Value="P"></asp:ListItem>    
<asp:ListItem Text="Expires after the close of:" Value="W"></asp:ListItem>
</asp:RadioButtonList>

function display()
{
    if(radiobuton is enabled)
          //code here
     else
          //code here
}

请提出一些想法来检测锄头以检查单选按钮是否禁用或启用

4

2 回答 2

9

使用 jQuery 附加到单选按钮列表的单击事件,然后使用 jQuery:enabled选择器,如下所示:

$('#rdStatus').click(function () {
    if($(this).is(':enabled')) { 
        // Do enabled radio button code here 
    }
    else {
        // Do disabled radio button code here
    }
});

现在您可以删除onclick单选按钮列表标记的属性,因为 jQuery 将找到单选按钮列表 ( rdStatus) 并为您连接点击事件。

<asp:RadioButtonList ID="rdStatus" runat="server" RepeatDirection="Vertical">
于 2013-09-24T05:11:34.897 回答
0

尝试这个:

<asp:RadioButtonList ID="rdStatus"  runat="server" RepeatDirection="Vertical">
<asp:ListItem Text="Temporary Waiver" Value="T" Selected="True"></asp:ListItem>    
<asp:ListItem Text="Never Expires" Value="P"></asp:ListItem>    
<asp:ListItem Text="Expires after the close of:" Value="W"></asp:ListItem>
</asp:RadioButtonList>

$("#<%=rdStatus.ClientID%>").click(function(){
    if($(this).attr('enabled'))
    {
        $(this).removeattr('enabled');
        $(this).attr('disabled',true);
    }
    else
    {
    }
});
于 2013-09-24T05:20:27.207 回答