【问题标题】:Escaping single quotes in view (kendo grid)在视图中转义单引号(剑道网格)
【发布时间】:2013-05-16 20:47:59
【问题描述】:

我有一个带有剑道网格的视图。

在下面的代码中,我的 '#=Name' 包含一个字符串。这个字符串有时有一个单引号。您可能已经猜到了,这个单引号正在扼杀我的 onclick 调用。

关于如何处理单引号有什么建议吗?

columns.Bound(p => p.ActiveAssetCount).ClientTemplate("<input type=\"button\" onclick=\"EntityPage.OpenWindow('#=EntityID#','#=Name.trim()#','true');\" name=\"ActiveAssetCount\" # if (ActiveAssetCount <= 0) { # style=\"display: none;\" # } else { # id=\"#=EntityID#\" class=\"AssetButton\" value=\"#= ActiveAssetCount # Assets\" # } # />").Width(120).Title("A. Assets").HeaderHtmlAttributes(new { @class = "AssetColumn" });

【问题讨论】:

    标签: jquery asp.net-mvc kendo-ui kendo-grid


    【解决方案1】:

    您可以将其编码为数据源中的 html 实体。使用&amp;apos;,或一个主要标记(html 实体的体面来源:http://www.danshort.com/HTMLentities/index.php?w=punct

    编辑:根据@Misi 的评论将&amp;lsquo; 更改为&amp;apos;

    【讨论】:

    • 对我来说它不起作用‘。 ’在 HTML5 中有效,但在 HTML4 中无效。
    猜你喜欢
    • 2013-01-01
    • 2020-11-30
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多