We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to check a CheckBox programmatically?

Hi,

I have a CheckBox like this:

@Html.EJ().CheckBox("CheckBoxRefreshed").Checked(false).CssClass("hidden")

I want to check this CheckBox programmatically from the client side(so to change to true the Checked property).

Thanks,
Cornel.

1 Reply

SP Sureshkumar P Syncfusion Team February 20, 2017 01:03 PM UTC

Hi Cornel, 
 
Thanks for contacting Syncfusion support, 
 
You can dynamically change the property value from code behind by creating instance of  the control. To showcase this, here we have changed the CheckBox “checked” property(API) value programmatically using the toggleButton’s client side change event 
 
Please refer the below code sample 
var btnObj; 
        $(document).ready(function () { 
            btnObj = $("#CheckBoxRefreshed").data("ejCheckBox"); 
        }); 
function tglebtnChange(e) {  //toggleButton’s client side Change event 
        //checkbox object (instance) creation to access the checkbox propertyies 
        if (e.isChecked) 
            btnObj.option("checked", true);  // change the checked property as true by using checkbox object 
        else 
            btnObj.option("checked", false); // change the checked property as false by using checkbox object 
 
    } 
 
 
For your convenience, we have created a sample to change the CheckBox state’s by using ToggleButton’s client side event https://www.syncfusion.com/downloads/support/forum/128959/ze/CheckBox_ClientSideEvent-952065350  
To know more about checkbox API, Events and Methods using below link: https://help.syncfusion.com/api/js/ejcheckbox  
Regards, 
Sureshkumar P 
 


Loader.
Up arrow icon