First thing I discover in your code, is that you have made a little spelling mistake, the first table tag is <tabel> not <table> as it should be. The second thing is that everytime that you want to write some Razor code inside some HTML you need to start the Razor engine, to tell that it need to be interpretedasRazor. You do this be using the @ character.
So try this code and see if you get your HTML table outputted.
@inherits Umbraco.Web.Macros.PartialViewMacroPage <table id="example"> @foreach (var page in allMagazines){ <tr> <td> test </td> </tr> } </table>
In the example above I am using a partial view macro, if you are using a partial view then you need to change this line
Whyed. All elements must be either self-closing or have a matching end tag.
Im getting that error code when im trying to save my macro in umbraco. Here is my code:
<tabel id="example">
foreach (var page in allMagazines)
{
<tr>
<td>
@:<a href="@page.Url"><div class="magazine-thumbnail">
<img src="@page.Media("magazineFrontpageImage", "umbracoFile")" width="155" height="220" />
<div class="details">
<p><strong>@page.magazineIssue</strong><br>@page.magazineTitle</p>
</div>
@:</div></a>
</td>
</tr>
}
</table>
Can anyone see why im getting this error?
Hi Nicolai,
First thing I discover in your code, is that you have made a little spelling mistake, the first table tag is <tabel> not <table> as it should be. The second thing is that everytime that you want to write some Razor code inside some HTML you need to start the Razor engine, to tell that it need to be interpreted as Razor. You do this be using the @ character.
So try this code and see if you get your HTML table outputted.
In the example above I am using a partial view macro, if you are using a partial view then you need to change this line
To
Hope this helps,
/Dennis
is working on a reply...