[RESOLVED] Javascript Runtime Error "Unable to set value of the property 'scriptsFailed': object is null or undefined" from dynamic user control

Hi Experts,

would like ask some help for my issue. I have a user control which is being loaded using "LoadControl" to a placeholder. this is done on server-side from a button click.

I have a user control that implements IScriptConttrol and is accompanied by javascript file which contains class prototype.

The user control then registers on the parent page's scriptmanager.RegisterScriptControl the script

protected override void OnPreRender(EventArgs e)
            scriptManager = ScriptManager.GetCurrent(Page);
            if (scriptManager == null)
                throw new HttpException("A ScriptManager control must exist on the page.");

            foreach (string attr in this.Attributes.Keys)
                mainContainer.Attributes.Add(attr, this.Attributes[attr]);


            // we overwrite the panel-ID with the control-ID -> we are able to adress it easily in an ASPX
            mainContainer.ID = this.ID;
            mainContainer.ClientIDMode = ClientIDMode.AutoID;



        protected override void Render(HtmlTextWriter writer)

        #region [ IScriptControl members ]
        IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
            yield return new ScriptControlDescriptor("Namespace.Designer", mainContainer.ClientID); ;

        IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
            return BundleConfig.getScriptReferences("~/bundles/xml", "~/bundles/scripts/designer");


If I include the user control in the Markup as <tag:Designer runat="server" id="designerControl"/>
I don't have a problem and everything works fine. 

But removing it and loading the user control dynamically at code-behind raises the javascript error "Unable to set value of the property 'scriptsFailed': object is null or undefined".

If I try to comment out the 


the page works fine. but I need the javascript class, so just to eliminate factors - I did this.

Is it conclusive that the approach above do not work for dynamic user controls? is there a workaround or am I missing something?

Need all any help i can get. I've been trying to find articles about the issue and how to resolve for half day already but no luck.

Thanks in advance.


script manager control should be placed before user control in aspx page, check if you have the correct sequence of controls.

thoughts on "[RESOLVED] Javascript Runtime Error "Unable to set value of the property 'scriptsFailed': object is null or undefined" from dynamic user control"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>