Templates and Content Security Policy (CSP)

0 Answers 67 Views
Template
AndreaG
Top achievements
Rank 1
AndreaG asked on 24 Jan 2024, 07:15 PM

I have an ASP.NET MVC project, using Kendo MVC 2023 R1, and I am using a strict CSP policy. However, the following code is not working

      <add name="Content-Security-Policy" value="script-src 'self'

Index.Cshml

<script id="editor-template" type="text/x-kendo-template">
          @Html.Kendo().TextBox().Name("FieldExcel").Enable(false).ToClientTemplate()    

</script>

 

in JS

$(document).ready(() => {
    $(".list-item-icon").on("click", e => {
        $("#edit-dialog").kendoWindow({
            height: 320,
            width: 415,
            title: 'Editar',
            visible: false
        });

        var thtml = $("#editor-template").html();

        var htmlEncode = kendo.htmlEncode;
        var templateString = () => thtml;

        var template = kendo.template(templateString);
        var data = { firstName: "Todd", age: 16 };

        var result = template(data);

        //var template = kendo.template($("#editor-template").html());
        $("#edit-dialog").data("kendoWindow").content(template({})).open().center();  

The result is a simple input text instead of a disabled Kendo control.

I have been trying many ways, and I can't find a solution


No answers yet. Maybe you can help?

Tags
Template
Asked by
AndreaG
Top achievements
Rank 1
Share this question
or