Copied to clipboard

Flag this post as spam?

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


  • Connie DeCinko 931 posts 1160 karma points
    Sep 20, 2013 @ 20:19
    Connie DeCinko
    0

    error CS1513: } expected

    I've just started with Razor and was looking to modify an existing cshtml file for news items. Funny thing is, the out-of-the-box razor file also fails with the same error when all I do is open and save it (from the uBootstrap package).

    When I try to save I get error CS1513: } expected. Below is my code. I've stripped it down to bare bones and cannot pin point the issue.

    @using umbraco.MacroEngines
    @inherits DynamicNodeContext
    @{
        var barEvents = Model.Descendants("EventsCalendar").First();
        foreach (var event in barEvents.Descendants("Event").Where("Visible").OrderBy("eventStartDateTime").Take(3))
        {
            <div>
                <div>@event.eventStartDateTime.ToString(@Dictionary.TimeFormat) - @event.eventEndDateTime.ToString(@Dictionary.TimeFormat)</div>
    
                <div style="float:left;">@event.eventImage</div>
                <div>
                    <h3><a href="@event.eventPage">@event.eventTitle</a></h3>
    
                    <p>@event.eventDescription</p>
                    <a href="@event.eventPage">Read More</a>
                </div>
            </div>
        }
    }
    
  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Sep 20, 2013 @ 21:00
    Andy Butland
    100

    Is it not just your choice of variable name - "event"?  That's a reserved word in C# so will probably cause an issue.

  • Connie DeCinko 931 posts 1160 karma points
    Sep 20, 2013 @ 22:25
    Connie DeCinko
    0

    Yep, that was it. I'm creating a list of events so the variable name made sense. I changed it back to item. Really hard to see the text was a different color in the editor on my monitor.

  • Connie DeCinko 931 posts 1160 karma points
    Sep 20, 2013 @ 22:27
    Connie DeCinko
    0

    Also, sounds like a bug fix needing to happen. The validator in the editor should have caught the use of the reserved word. The error thrown had nothing to do with anything.

Please Sign in or register to post replies

Write your reply to:

Draft