Completed
Last Updated: 29 May 2025 21:23 by Jeffrey
Release 2025 Q2 SP1
Derek
Created on: 22 May 2025 06:41
Category: Input
Type: Bug Report
4
Uncaught TypeError: Cannot read properties of null (reading 'className')

The issue occurs when setting the Enabled property to false, which triggers a JavaScript error and causes the components to break.

Code to replicate the problem

<telerik:RadTextBox ID="RadTextBox1" runat="server" Enabled="false"></telerik:RadTextBox>
10 comments
Jeffrey
Posted on: 29 May 2025 21:23

Agreed. The ASP.NET AJAX2025.2.528 (2025 Q2 SP1) hotfix seems to work fine so far.

Thanks for the quick turn-around on that.

Jeff

ADMIN
Rumen
Posted on: 28 May 2025 12:50

Hi Michael,

Thank you for the update, and I'm really sorry to hear about the trouble this issue caused in your application. We understand how frustrating and time-consuming unexpected behavior like this can be, especially when it's unclear where the problem originates.

We're glad to hear the hotfix resolved the issue on your end. Your patience and persistence are very much appreciated, and your feedback has been valuable throughout the resolution process.

If you encounter anything else or have further questions, please don't hesitate to reach out.

 

Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Michael
Posted on: 28 May 2025 12:35

This issue caused a mess in my app.  I spent several hours trying to figure out what I broke, before opening a ticket and being pointed to this article.

I just installed the hotfix and am happy to report it seems to fix the issue!

ADMIN
Rumen
Posted on: 28 May 2025 07:46
Hi everyone,

We are happy to share that we have just released Telerik UI for ASP.NET AJAX2025.2.528 (2025 Q2 SP1), and this release includes a fix for the JavaScript error that occurred when setting the Enabled property to false on certain input controls.

If you have previously applied one of the suggested workarounds (e.g. injecting JavaScript via MasterPage or IHttpModule), you can now safely remove it after upgrading.

We strongly recommend upgrading to the latest version to benefit from this fix.

Thank you all for your patience and feedback throughout the resolution process!

 

Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Daniel Jr.
Posted on: 27 May 2025 13:31

Hi,

We used option 2 to solve the problem. However, we had to modify it cause it was not working at first.

We had to put the line identified in the image below in a trycatch()

Thanks.

ADMIN
Attila Antal
Posted on: 23 May 2025 10:17

Dear developers,

Our team has agreed to fixing this in the next release, thus the workaround is only needed Temporarily.

I have also shared an additional approach in the Workaround section. This approach is intended to help developers who might be using many pages without a MasterPage and avoid editing all pages.

We apologize for any inconvenience this may have caused!

Regards,
Attila Antal
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Flavien
Posted on: 23 May 2025 09:31

Same problem

 

Jeffrey
Posted on: 22 May 2025 20:21

This same problem occurs with RadDatePicker controls also - only when disabled as you mention above.

I agree with Patrice that the workaround is not a good solution and would cause my client a lot of code changes. We have close to 1,000 pages in the site and it would be hard to determine which pages are affected. Also removing your workaround after you fix it would cause even more work.

If you can publish a hot-fix version soon, I would appreciate it.

Jeff Taylor

Patrice Boissonneault
Posted on: 22 May 2025 12:12
Will this fix be in next release? If so, we will wait here. We do not like workarounds. Thanks for confirming.
ADMIN
Attila Antal
Posted on: 22 May 2025 09:17

Hello Derek,

Thank you for reporting the problem! We have identified the issue in the source code and found a temporary workaround that can be used until a fix is released.

Workaround

A Temporary workaround for this would be to add the following JavaScript override to the project. 

Option 1

Place the following Script on the MasterPage to avoid duplicating the content for each page but it is important to be placed after ScriptManager/RadScriptManager declaration.

<script>
    (function () {
        try {
            var original_set_enabled = Telerik.Web.UI.RadInputControl.prototype.set_enabled;
            Telerik.Web.UI.RadInputControl.prototype.set_enabled = function (value) {

                if (this._enabled !== value) {
                    this._enabled = value;

                    if (this._textBoxElement) {
                        this._textBoxElement.disabled = !this._enabled;
                    }

                    if (this.get_wrapperElement())
                        this.updateCssClass();

                    this.updateClientState();

                    if (this.get_enableAriaSupport()) {
                        this._applyAriaStateChange('disabled', !value);
                    }

                    this.raisePropertyChanged('enabled');
                }
            }
        } catch (e) {
            // There is nothing to do.
        }
    })();
</script>

 

Option 2

In case the project Pages are not using a MasterPage and there are too many of them to edit, you can create a Custom Module which will inject the script to any Page that is served by the Web Server.

Create a class in the project that implements the IHttpModule interface. Note: Web Site projects require the class to be added to the App_Code folder

 

using System;
using System.Web;

namespace MyApplication.Modules
{
    public class ScriptInjectionModule : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.PreRequestHandlerExecute += (sender, e) =>
            {
                var app = (HttpApplication)sender;
                var page = app.Context.CurrentHandler as System.Web.UI.Page;
                if (page != null)
                {
                    page.PreRender += (s, args) =>
                    {
                        string script = @"
                        <script type='text/javascript'>
                        (function () {
                            try {
                                var original_set_enabled = Telerik.Web.UI.RadInputControl.prototype.set_enabled;
                                Telerik.Web.UI.RadInputControl.prototype.set_enabled = function (value) {
                                    if (this._enabled !== value) {
                                        this._enabled = value;
                                        if (this._textBoxElement) this._textBoxElement.disabled = !this._enabled;
                                        if (this.get_wrapperElement()) this.updateCssClass();
                                        this.updateClientState();
                                        if (this.get_enableAriaSupport()) this._applyAriaStateChange('disabled', !value);
                                        this.raisePropertyChanged('enabled');
                                    }
                                }
                            } catch (e) { }
                        })();
                        </script>";
                        if (!page.ClientScript.IsStartupScriptRegistered("TelerikInputFix"))
                        {
                            page.ClientScript.RegisterStartupScript(page.GetType(), "TelerikInputFix", script);
                        }
                    };
                }
            };
        }
        public void Dispose() { }
    }
}

 

Register the module through the web.config

 

<?xml version="1.0"?>
<configuration>
	<modules runAllManagedModulesForAllRequests="true">
		<add name="MyScriptInjectionModule" type="MyApplication.Modules.ScriptInjectionModule" />
	</modules>
</configuration>

 

 

Regards,
Attila Antal
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources