Wednesday 19 September 2012

JS : Disable Whole RadioButtonList by Javascript, No PostBack

Hello, Readers! 
http://forums.asp.net/t/1844055.aspx
Recently, I replied to an answer.
most of times we try no to postback (using updatepanel is another thing, we dont want to respond to the server for better performance.)
We can disable 1 radio button or item easily but how would be disable all RadioButtons or Checkboxes? which are dynamic, by SQLDatasource ETC.
I made this Jquery.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function toggleStatus() {
        var Drp = document.getElementById('DropDownList1');
        if (Drp.value == "Disable RadioList") {
                $('#some :input').attr('disabled', true);
            } else {
                $('#some :input').removeAttr('disabled');
            }
        } </script>

HTML Markup
<asp:DropDownList ID="DropDownList1" runat="server" onchange="toggleStatus()">
            <asp:ListItem>Enable RadioList</asp:ListItem>
            <asp:ListItem>Disable RadioList</asp:ListItem>
        </asp:DropDownList>
    
        <br /><div id="some">
        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
            <asp:ListItem>Good?</asp:ListItem>
            <asp:ListItem>Bad?</asp:ListItem>
            <asp:ListItem>No idea!</asp:ListItem>
        </asp:RadioButtonList></div>
It will disable All Radio Buttons of the Div "some"
Thanks for Reading..

3 comments:

rohini said...

Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this
Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune

Unknown said...

Excellent sir

lakshmik7410 said...

Thanks for sharing a useful blog!
data science training in chennai

ccna training in chennai

iot training in chennai

cyber security training in chennai

ethical hacking training in chennai

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More