Did this article resolve your question/issue?



Custom FormsControl JavaScript error in Sitefinity 7.1

« Go Back


TitleCustom FormsControl JavaScript error in Sitefinity 7.1
URL NameCustom-FormsControl-JavaScript-error-in-Sitefinity-7-1
Article Number000187567
EnvironmentProduct: Sitefinity
Version: 7.1
OS: All supported OS versions
Database: Microsoft SQL Server 2012 SP2
Question/Problem Description

When upgrading to Sitefinity 7.1 and a custom FormsControl widget is used, inheriting from Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl or a new custom FormsWidget is created, the following JavaScript error is likely to be received in the back-end page where the control is placed: "Uncaught ReferenceError: SitefinityWebApp is not defined."

Custom FormControl

Undefined error will be for the assembly and namespace the CustomFormsControl uses.

Steps to Reproduce
Clarifying Information

The new FormsControl has now a ScriptView and initializes client-side as well, since it has Ajax postbacks support upon form submission, as stated in the 7.1 Release notes: That is why, it is trying to initialize the custom control on the client side, however, it loads the default inherited control scripts references, which results in the custom namespace and control, not registered and not defined.

Error MessageUncaught ReferenceError: SitefinityWebApp is not defined.
Defect/Enhancement Number
Using custom FormsControl widget without overriding the script references causes client-side error on page edit.

The script references have to be overridden in order to register the custom control and initialize it client-side, as well. Add a simple JavaScript file to the control. It will be used to register the namespace and create the control using Microsoft.Ajax. Used it to also override default FormsControl functions.

1. Add the JavaScript file:


/// <reference name="MicrosoftAjax.js"/>
SitefinityWebApp.CustomForm = function (element) {
    SitefinityWebApp.CustomForm.initializeBase(this, [element]);
SitefinityWebApp.CustomForm.prototype = {
    /* --------------------------------- set up and tear down --------------------------------- */
    initialize: function () {
        SitefinityWebApp.CustomForm.callBaseMethod(this, 'initialize');
    dispose: function () {
        SitefinityWebApp.CustomForm.callBaseMethod(this, 'dispose');
SitefinityWebApp.CustomForm.registerClass('SitefinityWebApp.CustomForm', Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl);

2. Replace the namespace and class to match the custom control ones.

3. Make the JavaScript file Build Action to Embedded Resource.

4. Override the GetScriptReferences() method in the control, to reference the script as well as the default ones, since it inherits from them:


namespace SitefinityWebApp
    public class CustomForm : FormsControl
        public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
            string assemblyName = typeof(CustomForm).Assembly.FullName;
            var baseScripts = base.GetScriptReferences();
            var all = baseScripts.ToList();
            all.Add(new System.Web.UI.ScriptReference("SitefinityWebApp.CustomForm.js", assemblyName));
            return all;
Last Modified Date3/29/2017 2:08 AM
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.