Disabling all Telerik Controls on Single Page at Once

6 posts, 0 answers
  1. Kevin
    Kevin avatar
    7 posts
    Member since:
    Feb 2014

    Posted 26 Mar 2014 Link to this post

    Is there a way to use only a single command to disable all the telerik controls on a singe page in one command?

    If there isn't, they can still be disabled individually, but it is a nice time saving trick if there is.

    Note that we have found tutorials that describe how to individually make telerik controls read only, through programming code.  (Here is a good example: http://www.telerik.com/forums/programmatically-enabling-disabling-grid-row-editing)

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Mar 2014 in reply to Kevin Link to this post

    Hi Kevin,

    Please try the following JavaScript code snippet to disable all the Telerik controls.

    JavaScript:
    <script type="text/javascript">
        function pageLoad() {
            var allRadControls = $telerik.radControls;
            alert(allRadControls.length);
            for (var i = 0; i < allRadControls.length; i++) {
                allRadControls[i].set_enabled(false);
            }
        }
    </script>

    Thanks,
    Shinu.
  3. Kevin
    Kevin avatar
    7 posts
    Member since:
    Feb 2014

    Posted 01 Apr 2014 in reply to Shinu Link to this post

    Sorry for the delayed response.

    Is it possible to do this using only server side code (for security reasons)?

    *I am speaking on behalf of Kevin and have a programming background but not a telerik background.


  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Apr 2014 in reply to Kevin Link to this post

    Hi Kevin,

    In order to do it from server you need to access each control separately and you can disable it. Please have a look into the following C# code snippet which works fine at my end.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (var controls in form1.Controls.OfType<Telerik.Web.UI.RadComboBox>())
        {
            //access all the combobox in the page
            controls.Enabled = false;
        }
        foreach (var controls in form1.Controls.OfType<Telerik.Web.UI.RadTextBox>())
        {
            //access all the textbox in the page
            controls.Enabled = false;
        }
    }

    Hope this will helps you.
    Thanks,
    Shinu.
  5. Kristian Radolovic
    Kristian Radolovic avatar
    2 posts
    Member since:
    Aug 2005

    Posted 27 Jun in reply to Shinu Link to this post

    Well, a long time passed but i needed a script like this.

    I have only one issue: it doe's not disable radComboBoxes. 

    Any idea?

  6. Rumen
    Admin
    Rumen avatar
    14029 posts

    Posted 01 Jul Link to this post

    Hello,

    The server-side solution works 100% properly on my side:

    foreach (var controls in form1.Controls.OfType<Telerik.Web.UI.RadComboBox>())
    {
        //access all the combobox in the page
        controls.Enabled = false;
    }
    foreach (var controls in form1.Controls.OfType<Telerik.Web.UI.RadTextBox>())
    {
        //access all the textbox in the page
        controls.Enabled = false;
    }
    foreach (var controls in form1.Controls.OfType<Telerik.Web.UI.RadButton>())
    {
        //access all the textbox in the page
        controls.Enabled = false;
    }

    while the client-side needed some tweaking because you need to call the combobox disable() method:

    disable() instead of set_enabled()

    Check out this article: 
    https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/objects/radcombobox-object

    I hope this helps.

    Best Regards,
    Rumen
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top