Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have following code block in my Partial view. It gives error : } expected. But I don't understand what is the issue as {} pairs matches.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var langstr = "All"; var pageSize = 6; var max_pages=0; try { if (@ViewData["storylang"] == null) { langstr = ""; } else { langstr = @ViewData["storylang"].ToString(); } } catch (Exception ex) { langstr = ""; } var pageIndex = (int)@ViewData["page_index"]; dynamic selected; if (@ViewData["curpage"] != null){ var id = (int)@ViewData["curpage"]; var currentNode = Umbraco.TypedContent(id); selected = currentNode.Children.Where("Visible"); if(langstr != ""){ selected = currentNode.Children.Where("Visible").Where("language=\"" + @langstr + "\""); max_pages = currentNode.Children.Count(); <ul> @foreach (var story in selected.Take(pageIndex * pageSize)) { <li class="col-lg-3 col-md-3 col-sm-6 col-xs-12"><a href="story.Url" class="st-text">story.Name</a></li> } </ul> } } else { selected = CurrentPage.Children.Where("Visible"); max_pages = CurrentPage.Children.Count(); if(selected.Any()){ <ul> @foreach (var story in selected.Take(pageIndex * pageSize)) { <li class="col-lg-3 col-md-3 col-sm-6 col-xs-12"><a href="story.Url" class="st-text">story.Name</a></li> } </ul> } } }
can anyone debug the same?
Hi hrg,
I think there a issue with your syntax. You mixing code blocks and "rendering" blocks
Can you try this :
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var langstr = "All"; var pageSize = 6; var max_pages=0; try { if (ViewData["storylang"] == null) { langstr = ""; } else { langstr = ViewData["storylang"].ToString(); } } catch (Exception ex) { langstr = ""; } var pageIndex = (int)@ViewData["page_index"]; dynamic selected; } @if (ViewData["curpage"] != null){ var id = (int)ViewData["curpage"]; var currentNode = Umbraco.TypedContent(id); selected = currentNode.Children.Where("Visible"); if(langstr != ""){ selected = currentNode.Children.Where("Visible").Where("language=\"" + @langstr + "\""); max_pages = currentNode.Children.Count(); <ul> @foreach (var story in selected.Take(pageIndex * pageSize)) { <li class="col-lg-3 col-md-3 col-sm-6 col-xs-12"><a href="@story.Url" class="st-text">@story.Name</a></li> } </ul> } } else { selected = CurrentPage.Children.Where("Visible"); max_pages = CurrentPage.Children.Count(); if(selected.Any()){ <ul> @foreach (var story in selected.Take(pageIndex * pageSize)) { <li class="col-lg-3 col-md-3 col-sm-6 col-xs-12"><a href="@story.Url" class="st-text">@story.Name</a></li> } </ul> } }
Dave
Thanks ... it solved the issue. I got it.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
: } expected umbraco razor
I have following code block in my Partial view. It gives error : } expected. But I don't understand what is the issue as {} pairs matches.
can anyone debug the same?
Hi hrg,
I think there a issue with your syntax. You mixing code blocks and "rendering" blocks
Can you try this :
Dave
Thanks ... it solved the issue. I got it.
is working on a reply...