【问题标题】:Telerik MVC problem with window and Razor view engine窗口和 Razor 视图引擎的 Telerik MVC 问题
【发布时间】:2011-08-14 14:54:33
【问题描述】:

我正在尝试升级我的项目以使用 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">
-----------------------

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

谢谢

【问题讨论】:

    标签: asp.net-mvc-3 razor telerik-mvc


    【解决方案1】:

    你应该像这样改变你的代码:

    旧:

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

    新:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 抱歉,您能否更具体地说明括号的位置?谢谢
      • @nixon: @(Html.Teleirk.Whatever...)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-24
      • 2011-06-29
      相关资源
      最近更新 更多