Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Kingo Damgaard 157 posts 456 karma points
    Mar 08, 2013 @ 16:02
    Bo Kingo Damgaard
    0

    Razor code rendered as whitespace

    Hi

    I have a small issue when rendering a contour form that the razor code in the view files is rendered as whitespace. This FieldType.Textfield.cshtml view is modified slightly but it's the same problem with the original:

    @model Umbraco.Forms.Mvc.Models.FieldViewModel
    <div class="controls">
    <input type="text" name="@Model.Name" id="@Model.Id" value="@Model.Value" maxlength="500"
        @{if(Model.Mandatory || Model.Validate){<text>data-val="true"</text>}}
        @{if (Model.Mandatory) {<text> data-val-required="@Model.RequiredErrorMessage"</text>}}
        @{if (Model.Validate) {<text> data-val-regex="@Model.InvalidErrorMessage" data-regex="@Model.Regex"</text>}}
        />
    </div>

    The line

    @model Umbraco.Forms.Mvc.Models.FieldViewModel

    is rendered out as whitespace meaning "                                                                  " is inserted between my label and the input field, and it messes with my layout.

    How to fix this?

    Kind Regards

    Bo

     

  • Bo Kingo Damgaard 157 posts 456 karma points
    Mar 10, 2013 @ 13:40
    Bo Kingo Damgaard
    100

    This is bloody weird. If I remove the offending @model line, save the .cshtml, refresh the page, reinsert the line, save the .cshtml and refresh the page, it works! I have to the same over again on each FieldType.*.cshtml file though.

    EDIT:
    Actually that wasn't enough. You have to wrap the line on @{}, save the file, refresh the page and get an error, reinsert the original line, save the file, and now it works.

    This line

     @model Umbraco.Forms.Mvc.Models.FieldViewModel

    should be wrapped like this

    @{
    @model Umbraco.Forms.Mvc.Models.FieldViewModel

    Save the file, and reload the page, and remove the wrap again, sa ve at it works.

    Don't what is going on, but it doesn't make any sense

    /Bo

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies