object required error in Template File Editor

May 3, 2012 at 7:59 AM
Edited May 3, 2012 at 8:02 AM

When we try  to open the Template File Editor from Template Manager,we see a javascript error 

saying "object required" in Codemirror.js file. The error was due to the value of the textarea being undefined.

This is the screenshot from IE.

and here is the solution to this error.

Go to Modules/TemplateFileManager/TemplateFilemanager.ascx and replace the code.


 var id = '<%=txtEditor.ClientID%>';
       if(typeof $('#'+id).val()!='undefined')
            var editor = CodeMirror.fromTextArea(document.getElementById(id), {
                mode: "application/xml",
                lineNumbers: true,
                onCursorActivity: function() {
                    editor.setLineClass(hlLine, null);
                    hlLine = editor.setLineClass(editor.getCursor().line, "activeline");
            var hlLine = editor.setLineClass(0, "activeline");

Here, the codemirror initialization part is put inside the if condition


if(typeof $('#'+id).val()!='undefined')
       {  }

condition and this seems to solve the problem.