Wednesday, 2 November 2016


Watch this on YouTube:


0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'checked'

To fix it - replace
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            $(document).ready(function () {
                $('.rb').click(function () {
                    if ($('#RadioButton1').checked()) {
                        alert('radio button 1 checked');                   
                    } else {
                        alert('radio button 2 checked');
                    }
                   
                });
            });
        </script>
    <div>
        <asp:RadioButton ID="RadioButton1" runat="server" GroupName="GroupOne" />
        <asp:RadioButton ID="RadioButton2" runat="server" GroupName="GroupOne"/>
        <asp:Button ID="Button1" class="rb" runat="server" Text="Button" />
    </div>
    </form>
</body>

With
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            $(document).ready(function () {
                $('.rb').click(function () {
                    if ($('#RadioButton1').attr('checked')) {
                        alert('radio button 1 checked');                   
                    } else {
                        alert('radio button 2 checked');
                    }
                   
                });
            });
        </script>
    <div>
        <asp:RadioButton ID="RadioButton1" runat="server" GroupName="GroupOne" />
        <asp:RadioButton ID="RadioButton2" runat="server" GroupName="GroupOne"/>
        <asp:Button ID="Button1" class="rb" runat="server" Text="Button" />
    </div>
    </form>
</body>

No comments:

Post a Comment