0

我正在尝试升级我的项目以使用 Razor。我使用 Telerik 转换工具https://github.com/telerik/razor-converter 将我的视图转换为 Razor,但我收到与 Telerik Window 控件相关的错误。

下面是窗口控件的标记示例:

@Html.Telerik().Window()
   .Name("ClientWindow")
    .Content(@<text>

        <div id="Div1">
            <div class="bgTop">
                <label for="drpFilter">
                    Filter:</label>
                @Html.DropDownListFor(x => x.ClientLookupViewModel.SelectedFilter, Model.ClientLookupViewModel.FilterBy, new { id = "drpClientFilter" })
                <label>
                    By:</label>
                @Html.TextBoxFor(x => x.ClientLookupViewModel.FilterValue, new { id = "filterValue" })

                <button type="button" value=" " class="t-icon t-refresh refreshButton" title="Refresh Client &amp; Matter"
                    onclick="refreshClientClicked()">
                </button>
                @Html.ValidationMessageFor(x => x.ClientLookupViewModel.FilterValue)
            </div>
            <iframe id="frameClientLookup" src="@Url.Action("ClientIndex","Lookup")" style="border: 0px;
                height: 404px; width: 100%; margin: 0px; padding: 0px;"></iframe>
            <div class="bgBottom">
                <input style="float: right; margin-top: 5px" type="button" value="OK" id="Button1" onclick="btnClientOkayClicked()" /></div>
        </div>

   </text>)
    .Modal(true)
    .Width(800)
    .Height(473)
   .Title("Client Lookup")
   .Buttons(buttons => buttons.Refresh().Maximize().Close())
   .Visible(false)
   .HtmlAttributes(new { id = "ClientWindow" })
   .Render();

这给出了以下错误

解析器错误描述:解析服务此请求所需的资源时发生错误。请查看以下特定的解析错误详细信息并适当地修改您的源文件。

解析器错误消息:“<”在代码块的开头无效。只有标识符、关键字、注释、"(" 和 "{" 是有效的。

源错误:

Line 41:             @Html.Telerik().Window()
Line 42:        .Name("ClientWindow")
Line 43:         .Content(@<text>
Line 44:             
Line 45:             <div id="Div1">
-----------------------

有谁知道这里的问题是什么?

谢谢

4

2 回答 2

3

您应该像这样更改代码:

老的:

@Html.Telerik().Window()
 /* rest is omitted for brevity */
.Render();

新的:

@ { 
  Html.Telerik().Window()
 /* rest is omitted for brevity */
  .Render(); 
}
于 2011-05-06T07:53:33.407 回答
0

由于该代码块中有空格和换行符,因此您需要将整个内容括在括号中,以强制 Razor 继续解析它超过换行符。

于 2011-04-28T11:38:40.643 回答