how i can translate this code into razor syntax:
<% for (int i = 0; i < items.Length; i++) %>
<%{
if (i % 3 == 0)
{ %>
<tr>
<% } %>
<td><a href="<%: url[i] %>"><%: title[i] %></a></td>
<% if (i % 3 == 2)
{ %>
</tr>
<% } %>
<%} %>
i'm try, but not success:
@for (int i = 0; i < items.Length; i++)
{
if (i % 3 == 0)
{
<tr>
}
<td><a href="@(url[i])">@(title[i])</a></td>
if (i % 3 == 2)
{
</tr>
}
}
i have find solution:
@for (int i = 0; i < items.Length; i++)
{
if (i % 3 == 0)
{
@:<tr>
}
<td><a href="@url[i]"><img height="@(48 * Scale.Value)" width="@(48 * Scale.Value)" src="/i@(Scale.Value)/@(items[i]).png"/><span>@text[i]</span></a></td>
if (i % 3 == 2)
{
@:</tr>
}
}
here is introduction to razor syntax, but:
Use the @: operator or the
<text>element. The @: outputs a single line of content containing plain text or unmatched HTML tags; the element encloses multiple lines to output. These options are useful when you don’t want to render an HTML element as part of the output.
i don't know, why <text> now working. maybe because razor still RC, not release
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With