Can I use Kendo MVC helpers inside templates?

2019-05-28 14:54发布

问题:

I need to use Kendo MVC helper Razor code in template as listed below:

<script id="some-reusable-control" type="text/x-kendo-template">
    @(Html.Kendo().Window()
        .Name("details-window"))
</script>

But the problem is rendered HTML+JS contains a # (sharp symbol) that is rendered as part of #= # syntax inside template. So I getting 'parse error'.

<div id="details-window" style="display:none"></div><script>
 jQuery(function(){jQuery("#details-window
").kendoWindow({animation:false,modal:true,draggable:true /*, etc */ });});
</script>

Could anyone please provide me a solution of how to use Kendo helpers in templates.

回答1:

To use Kendo UI Widgets as content for a template you could use the ToClientTemplate method. e.g.

<script id="some-reusable-control" type="text/x-kendo-template">
  @(Html.Kendo().Window()
      .Name("details-window")
      .ToClientTemplate())
</script>


标签: kendo-ui