No matter what I do, I get an error telling me some ending bracket is missing in my Razor macro. Driving me nuts. Has anyone else run into this problem?
Spotted it. You're using 'event' as your variable name in the last foreach. I bet it's throwing a fit because it's a C# keyword. Change it (and the uses of it) to something like 'child' and it works.
<div class="tabs-container"> @foreach (var day in @Model.scheduleDay.Where("Visible")) { <div id="@day.Id" class="tab-content"> @if(day.Children.Count() != 0) { foreach(var time in @day.Children) { <h3>@time.Name</h3> if(time.Children.Count()>0) { foreach(var childin time.Children) { var photo = @child.image; <h2>@child.title</h2>
if (!String.IsNullOrEmpty(photo)) { <img src="/ImageGen.ashx?image=@child.image&width=150" alt="@child.title" class="photo" /> }
Return to Bracket Hell
No matter what I do, I get an error telling me some ending bracket is missing in my Razor macro. Driving me nuts. Has anyone else run into this problem?
For example, what's wrong with this code? The brackets are totally balanced as far as a I can see:
<div class="tabs-container">
@foreach (var day in @Model.scheduleDay.Where("Visible"))
{
<div id="@day.Id" class="tab-content">
@if(day.Children.Count() != 0){
foreach(var time in @day.Children){
<h3>@time.Name</h3>
if(time.Children.Count()>0){
foreach(var event in time.Children){
var photo = @event.image;
<h2>@event.title</h2>
if(!String.IsNullOrEmpty(photo)){<img src="/[email protected]&width=150" alt="@event.title" class="photo" />}
<p>@event.description</p>
}
}
}
}
</div>
}
</div>
Spotted it. You're using 'event' as your variable name in the last foreach. I bet it's throwing a fit because it's a C# keyword. Change it (and the uses of it) to something like 'child' and it works.
<div class="tabs-container">
@foreach (var day in @Model.scheduleDay.Where("Visible"))
{
<div id="@day.Id" class="tab-content">
@if(day.Children.Count() != 0)
{
foreach(var time in @day.Children)
{
<h3>@time.Name</h3>
if(time.Children.Count()>0)
{
foreach(var child in time.Children)
{
var photo = @child.image;
<h2>@child.title</h2>
if (!String.IsNullOrEmpty(photo))
{
<img src="/ImageGen.ashx?image=@child.image&width=150" alt="@child.title" class="photo" />
}
<p>@child.description</p>
}
}
}
}
</div>
}
</div>
DOH!!! You're right! Oh man, I'm a moron!
Can I buy you a beer? ;-)
Don't be so hard on yourself, easy mistake to make! I'd have done the same thing no doubt.
High five/mark the answer and we're even :-)
is working on a reply...