Telerik MVC 窗口和 Razor 视图引擎问题

发布于 2024-11-04 00:39:20 字数 2262 浏览 6 评论 0原文

我正在尝试升级我的项目以使用 Razor。 我使用了Telerik转换工具 https://github.com/telerik/razor -转换器 将我的视图转换为 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();

这给出了以下错误

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

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

源错误:

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

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

谢谢

I'm trying to upgrade my project to use Razor.
I have used the Telerik conversion tool https://github.com/telerik/razor-converter
to convert my views to Razor but I am getting errors related to the Telerik Window control.

Here is an example of the markup for the window control:

@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 & 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();

This gives the following error

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: "<" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

Source Error:

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

Does anyone know what the problem is here ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱给你人给你 2024-11-11 00:39:20

您应该像这样更改代码:

旧:

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

新:

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

You should change your code like this:

OLD:

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

NEW:

@ { 
  Html.Telerik().Window()
 /* rest is omitted for brevity */
  .Render(); 
}
悟红尘 2024-11-11 00:39:20

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

Since you have whitespace and newlines in that code nugget, you need to wrap the whole thing in parentheses to force Razor to continue parsing it past the newline.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文