New to Kendo UI for jQuery? Download free 30-day trial

'Invalid Template' Error Occurs When Using Localization and Templates


Product Progress® Telerik® UI for ASP.NET Core


My UI for ASP .NET Core project uses a Kendo UI Grid with templates and localization of the resource files. The Kendo UI HTML helper generates hash tag symbols, such as Иден, which cause an error.

Error Message

Uncaught Error: Invalid template:'....'


ASP.NET Core encodes all Unicode characters except the ones from the BasicLatin range. The encoded characters are similar to 汉. The hash sign (#) in the encoded character representation has a special meaning inside the Kendo UI templates and breaks their syntax, which results in throwing the Invalid template error.


Widen the character ranges that are treated as safe by the ASP.NET Core encoding mechanism. This approach will prevent the framework from encoding your localized strings.

  1. Open Startup.cs file and locate the ConfigureServices method.
  2. Add the following line:

     services.AddSingleton(HtmlEncoder.Create(allowedRanges: new[] { UnicodeRanges.BasicLatin,
                                                                     UnicodeRanges.Cyrillic }));

    Inside the code line, replace UnicodeRanges.Cyrillic with the ranges which include all Unicode characters that you use in your localization files. For more information, refer to the relevant table in the Unicode Character Code Charts list. The final result should be similar to the following code snippet:

        public void ConfigureServices(IServiceCollection services)
            // Add framework services.
                .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
            services.AddSingleton(HtmlEncoder.Create(allowedRanges: new[] { UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic }));

See Also

In this article