0

我有以下客户端模板...

.ClientTemplate("<a href='javascript:showQuestionChoiceWindow('<#= QuestionId #>') class='t-button t-grid-edit'>Choices</a>").Title("");

呈现上述内容时,我得到以下输出:

<a class="t-button t-grid-edit" 971405d2-a08a-436a-ab79-7e45961c5ffb')=""href="javascript:showQuestionChoiceWindow(">Choices</a>

基本上,我的简单替换字符串已被移动,导致语法无效。删除占位符可以更正语法,但我需要注入的值。

4

2 回答 2

1

您可以尝试将类声明分开并将其放入 HtmlAttributes 中。

.ClientTemplate("<a href='javascript:showQuestionChoiceWindow(<#= QuestionId #>)'>Choices</a>").Title("").HtmlAttributes(new { @class = "t-button t-grid-edit" })
于 2012-07-13T14:09:48.873 回答
1

您已嵌套'在模板中,因此存在问题。试试这个(注意 href 属性使用\"):

.ClientTemplate("<a href=\"javascript:showQuestionChoiceWindow('<#= QuestionId #>')\"  class='t-button t-grid-edit'>Choices</a>").Title("");
于 2012-07-18T10:13:30.027 回答