RadButtons OnClientCheckedChanged

5 posts, 1 answers
  1. Patrick
    Patrick avatar
    29 posts
    Member since:
    May 2011

    Posted 07 Sep 2011 Link to this post

    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)
  2. Answer
    Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 07 Sep 2011 Link to this post

    Hmmm, what about this jQuery version?

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


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Patrick
    Patrick avatar
    29 posts
    Member since:
    May 2011

    Posted 08 Sep 2011 Link to this post

    Thanks, that works.
     Now, does anyone know why that works and mine didn't?

    Thanks,
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 08 Sep 2011 Link to this post

    Does it have to be
    document.getElementById("id")

    ...I'm way more familiar with jQuery so I don't totally know :o
  6. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 09 Sep 2011 Link to this post

    Hello Patrick,

    Steve is right, the reason your code didn't work is because you didn't use document.getElementById.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017