在视图中转义单引号(剑道网格)

Mit*_*all 4 asp.net-mvc jquery kendo-ui kendo-grid

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

在接下来的一段代码中,我的 '#=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" });
Run Code Online (Sandbox Code Playgroud)

Pat*_*k M 5

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

编辑:@Misi&lsquo;改为&apos;每条评论。