This is a migrated thread and some comments may be shown as answers.

RadButtons OnClientCheckedChanged

4 Answers 111 Views
Button
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 07 Sep 2011, 04:11 PM
Okay, i'm doing something very simple, so i must not be understanding something.

Goal: Show a Table Row when the checkbox is checked, hide it when it's unchecked.

Javascript =
function toggleRelationshipRow(sender, args) {
            var row = getElementById("ctl00_ContentPlaceHolder1_rowRelationship");
            if(args.get_checked())
                row.style.display = '';
            else
                row.style.display = 'none';
}
The row i'm referencing exists with that ID. Gives me the same id if I use

<%=rowRelationship.ClientID%>

 


TelerikRadButton Code:

<telerik:RadButton ID="cbIsLeaker" runat="server" 
       ToggleType="CheckBox" ButtonType="ToggleButton" 
        ToolTip="Flag as Leaker" AutoPostBack="False" Checked="false"  
        OnClientCheckedChanged="toggleRelationshipRow" >
  </telerik:RadButton>

The event is firing, but i'm getting an Object Expected error on the getElementById call, which I don't understand, the Row exists with the id.

Thanks for any help, (and i wouldn't be surprised if there is something i'm not doing right w/ my javascript)

4 Answers, 1 is accepted

Sort by
0
Accepted
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 08 Sep 2011, 02:17 AM
Hmmm, what about this jQuery version?

function toggleRelationshipRow(sender, args) {
    var row = $telerik.$("[id$='rowRelationship']");
    if(args.get_checked())
        row.show();
    else
        row.hide();
}


0
Patrick
Top achievements
Rank 1
answered on 08 Sep 2011, 03:51 PM
Thanks, that works.
 Now, does anyone know why that works and mine didn't?

Thanks,
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 08 Sep 2011, 04:00 PM
Does it have to be
document.getElementById("id")

...I'm way more familiar with jQuery so I don't totally know :o
0
Kevin
Top achievements
Rank 2
answered on 09 Sep 2011, 12:59 PM
Hello Patrick,

Steve is right, the reason your code didn't work is because you didn't use document.getElementById.
Tags
Button
Asked by
Patrick
Top achievements
Rank 1
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Patrick
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Share this question
or