Can I use Kendo MVC helpers inside templates?

纵然是瞬间 提交于 2019-12-10 11:08:51

问题


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>


来源:https://stackoverflow.com/questions/16383972/can-i-use-kendo-mvc-helpers-inside-templates

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!