更正客户端模板中的语法以添加 Actionlink 和条件语句

Correct Syntax in Client Template to add Actionlink along with conditional statement

我尝试了多次尝试添加 html.actionlink 以及 kendo 网格中客户端模板中的条件。可以请任何人帮助正确的语法。 谢谢

col.Bound(o => o.IsEmpolymentFileExist).ClientTemplate("# if( IsEmpolymentFileExist == true) { # @Html.ActionLink("OpenFile", "Openfile", "PreEmploymentWorkflow", new { Id = "#=PreEmploymentId#", uploadfilename = "Employment Application" }, new { @class = "classname3" }).ToHtmlString() # } else {# <img ... /> # } #")

您需要将模板语法用引号括起来,然后是操作 link,然后是最终的模板语法:“...模板...”+@ Html.Actionlink(...).ToHtmlString() + "...模板...",所以试试:

.ClientTemplate("# if( IsEmpolymentFileExist == true) { #" + @Html.ActionLink("OpenFile", "Openfile", "PreEmploymentWorkflow", new { Id = "#=PreEmploymentId#", uploadfilename = "Employment Application" }, new { @class = "classname3" }).ToHtmlString() + "# } else {# <img ... /> # } #")

不确定 {# <img ... /> # } 是否也需要在散列中。