Detect whether radio button is disabled or enabled [duplicate]
Asked Answered
O

2

19
<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
}

Please suggest some idea to detect hoe to check radiobutton is disable o enable

Owlet answered 24/9, 2013 at 5:3 Comment(1)
can you share the generated html instead of asp codeTakamatsu
G
9

Use jQuery to attach to the click event of the radio button list and then use the jQuery :enabled selector, like this:

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

Now you can remove the onclick attribute of your radio button list markup, because jQuery is going to find the radio button list (rdStatus) and wire up the click event to it for you.

<asp:RadioButtonList ID="rdStatus" runat="server" RepeatDirection="Vertical">
Grillwork answered 24/9, 2013 at 5:11 Comment(2)
onclick="javacript:display();" here what modification i have to madeOwlet
@Owlet - updated answer to use jQuery event handler instead of markup using onclick attribute.Grillwork
P
0

Try this:

<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
    {
    }
});
Pend answered 24/9, 2013 at 5:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.