I am trying to disable(readonly) and enable a RTE field on toggle of a checkbox in the Content Editor. The John west blogs tells to alter the "renderContentEditor" Pipeline which I guess will not be a efficient way of doing as this will get called every time and the performance will get a hit. https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/use-a-checkbox-to-control-section-visibility-in-the-sitecore-asp-net-cms https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/render-content-editor-fields-read-only-in-the-sitecore-asp-net-cms.

Can I go with a custom Checkbox field that triggers to make the RTE field readonly when selected and editable when not selected? What is the best efficient way of handling this and how to achieve it?

  • You will need to go through the renderContentEditor pipeline because it is at this point that the content editor is rendering the fields for the item. Apr 10, 2018 at 7:08

2 Answers 2


You could perhaps do this by injecting some custom JavaScript into content editor like so with a pipeline:


   var page = HttpContext.Current.Handler as Page;
foreach (string script in _scripts)
        new LiteralControl(
            "<script type='text/javascript' language='javascript' src='{0}'></script>".FormatWith(script)));

Patch configuration

    <processor patch:before="*[1]"
               type="{Namespace}.InjectContentEditorResources, {Assembly}">
        <scripts hint="list:addScriptResource">

Then in your JavaScript you can do some jquery to select your checkbox and so checks to enable/disable the field like so:

 $sc(document).ready(function(event) {
    $sc('.field-selector').each( function(index) {
        //enable or disable here

More info on doing this here:




If you are creating your own custom field (the checkbox, in your case), then I believe you can insert some javascript as in:

protected override void DoRender(HtmlTextWriter output)


and in method GetJavascriptCode() you would do:

public string GetJavascriptCode()
    //  JS code to handle the change state of the radio buttons
    var js = string.Format(@"<script>

        $scj = jQuery.noConflict();

        $scj(document).ready(function(event) {{ 

            if ($scj('#CheckboxID').prop('checked')) {{
                // find RTE control and disable it
    return js;

You would have to hard-code the selector for the RTE control. For example, its ID or Class, etc (considering you have no control on how the RTE field is being rendered).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.