0
votes

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

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

2

2 Answers

3
votes

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(); 
}
0
votes

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.