This is a migrated thread and some comments may be shown as answers.

Disabling all Telerik Controls on Single Page at Once

5 Answers 525 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 26 Mar 2014, 01:10 PM
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)

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2014, 03:12 AM
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.
0
Kevin
Top achievements
Rank 1
answered on 01 Apr 2014, 12:52 PM
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.


0
Shinu
Top achievements
Rank 2
answered on 02 Apr 2014, 03:08 AM
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.
0
Kristian Radolovic
Top achievements
Rank 1
answered on 27 Jun 2019, 09:05 AM

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?

0
Rumen
Telerik team
answered on 01 Jul 2019, 10:54 AM
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.
Tags
General Discussions
Asked by
Kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Kristian Radolovic
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or