@{ // you have entered "code mode" here - unless you open an html tag it will stay in "code mode"
var DocContentPage = DocPage.docNested;
foreach (var item in DocContentPage)
{
var SelectionId = item.DocumentFilter;
string RadioTextValue = umbraco.library.GetPreValueAsString(SelectionId);
if (RadioTextValue == "Trust Documents")
{
<div class="col-md-6">
@* you have entered into html mode ! *@
<h3>@item.DocumentTitle</h3>
<p>@item.DocumentDescription</p>
<p><a class="btn btn-secondary" href="@item.FileUpload.Url" target="_blank" role="button"><i class="fas fa-file-pdf"></i> View here</a></p>
</div>
}
}
}
foreach and if error
Hello
I am writing a piece of code that pulls content from another page.
The page should only display the associated content of that page and therefore need a ForEach and If statement.
This is what I have so far.
The error I get is:
Source Error:
Line 293: } Line 294: } Line 295:}
Source File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\f96f3538\6042b992\AppWebdocumentdisplaycontent.cshtml.65a2d1ee.dyfupqad.0.cs Line: 295
I cannot understand why this is happening, I believe it has something to do with the if statement but not sure what.
Thanks
Hi,
It's important to understand in Razor when you need a @ and when you don't.
Imagine it as a switch - you only need it to switch from "html mode" to "code mode".
If you're already in "code mode" then don't use @ s!
Steve
Steve thank you very much sorted.
Never come across that before.
is working on a reply...