Want to only check checkbox after confirm

3 posts, 1 answers
  1. Harry
    Harry avatar
    2 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    I have a checkbox defined as

    <telerik:RadButton ID="checkbox1" runat="server" Text="testing" ButtonType ="ToggleButton" ToggleType="CheckBox" OnClientClicked="checkbox1_ClientClicked"></telerik:RadButton>

    What I want to do in the ClientClicked event is only check the box (and uncheck a different checkbox) when the user selects OK. Everything else seems to work fine but even though the last thing I do in the "ok" case is .set_checked(false) the box remains checked. Here is the javascript:

                function checkbox1_ClientClicked(sender, eventArgs) {
                    var checkbox1 = $find('<%=checkbox1.ClientID%>');
                    function CallbackFn(arg) {
                        if (arg) {
                            var checkbox1 = $find('<%=checkbox1.ClientID%>');  // I know I probably don't need this, just being safe
                            var checkbox2 = $find('<%=checkbox2.ClientID%>');
                            checkbox1.set_checked(true);
                            checkbox2.set_checked(false);
                        }
                        else {
                            checkbox1.set_checked(false);
                        }
                    }
                    if (checkbox1.get_checked()) {
                        return radconfirm("warning text", CallbackFn, 330, 150, null, "title");
                    }
                }

    I've also tried the ClientCheckedChanged and ClientCheckedChanging events with similar results. What obvious, basic thing am I missing? 8^)
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jun 2014 in reply to Harry Link to this post

    Hi Harry,

    Please try the below JavaScript to check the CheckBox based on RadConfirm.

    JavaScript:
    function checkbox1_ClientClicked(sender, args) {
        sender.set_checked(false);
        var confirm = radconfirm("Are you Sure?", callBackFn, 300, 200, null, "Confirm", null);
    }
    function callBackFn(arg) {
        var checkbox = $find("<%=radbtnTestingCheckbox.ClientID%>");
        checkbox.set_checked(arg);
    }

    Thanks,
    Shinu.
  3. Harry
    Harry avatar
    2 posts
    Member since:
    Jun 2014

    Posted 12 Jun 2014 in reply to Shinu Link to this post

    That worked! The main difference seems to be using 'sender' rather than the object returned from $find, though I would have thought they pointed to the same object. Still new to JS so there's probably a nuance I'm missing. Many thanks!
Back to Top