New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

SyntaxError Occurs in the Browser

Environment

Product Progress® Telerik® UI for ASP.NET AJAX AjaxManager Progress® Telerik® UI for ASP.NET AJAX AjaxPanel

Description

Depending on the browser, the following errors occur:

  • SyntaxError in Internet Explorer

  • Uncaught SyntaxError: Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule' in Chrome

  • SyntaxError: An invalid or illegal string was specified in FireFox

Cause

The cause for these errors are the commented CSS rules in the <head> of your page, for example, /* .someClass { display: none; } */. The AjaxManager and Ajaxpanel update the <head> of the page to enable controls to register stylesheets and scripts during an AJAX request. Such commented rules cannot be parsed by the engine.

Solution

To solve this issue, use any of the following approaches:

  • Set the EnablePageHeadUpdate property of the Ajax control to false.

  • Remove the commented CSS rule or move it to a separate stylesheet file.

  • Place the styles settings in external CSS files.

In this article