Can anyone convert this ASP.NET syntax to RAZOR syntax? I can not convert it "one to one" to Razor syntax.
<% Themes.ThemesAvailable().ForEach(i =>
{
if (i.Equals(Themes.ThemeToUse))
{%>
<a href="" id="A1" style="font-size:x-large;color:Red"><%:i%></a>
<%}
else
{%>
<a href="" style="color:Blue" id="ChangeThemeTo_<%:i%>"><%:i%></a>
<%} %>
<br />
<% });%>
The following does not work (complains about CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement)
@Themes.ThemesAvailable().ForEach(i => {
if (i.Equals(Themes.ThemeToUse)){
@:<a href="" id="A1" style="font-size:x-large;color:Red"> + @i + </a>
;}else{
@:<a href="" style="color:Blue" id='ChangeThemeTo_@i'>@i</a>
;} })
and this does not work (suddenly it expects '}' at top of the page line1 col1)
@Themes.ThemesAvailable().ForEach(i =>
{
if (i.Equals(Themes.ThemeToUse)){
@<text><a href="" id="A1" style="font-size:x-large;color:Red"> + @i + </a></text>
;} else {
@<text><a href="" style="color:Blue" id='ChangeThemeTo_@i'>@i</a></text>
;}
})
Seems The @i within id='ChangeThemeTo_@i' stops the end text-tag from working. If I remove the '@' the element works. But get the same error as the first conversion try (CS0201).
Removing the usage of lambda, this works, but ONLY if I remove the '@' from id='ChangeThemeTo_i'
@foreach (var i in Themes.ThemesAvailable()){
if (i.Equals(Themes.ThemeToUse)){
<a href="" id="A1" style="font-size:x-large;color:Red"> + @i + </a>
} else {
<a href="" style="color:Blue" id='ChangeThemeTo_i'>@i</a>
}
}