Here is some code on my ASP.NET site. I initially wanted to write
if((n%4)==0) {
<div>
}
//code
if((n%4)==0) {
</div>
}
but ASP.NET wouldn't have it. It had a compile error. It appears it ignores }
until I close the div
. So I ended up with the below. The if statement causes me the same problem. I know I can conditionally have values by writing class="@(cond?"val":"")"
but that only works for values I don'
t know how to conditionally have checked
in there. Having the same line written 4 times is pretty ridiculous how do I write this properly?
<div>
@for (int i = 1, n = 0; i < 32; i <<= 1, ++n)
{
if ((looking & i) != 0)
{
<input type="checkbox" name="SomeName" value="@i" id="SomeName_@i" checked>
}
else
{
<input type="checkbox" name="SomeName" value="@i" id="SomeName_@i">
}
<label for="SomeName_@i">@TestApp.Controllers.HomeController.enumFriendlyName[n]</label><br />
}
</div>
<div>
@for (int i = 32, n = 4; i < 256; i <<= 1, ++n)
{
if ((looking & i) != 0)
{
<input type="checkbox" name="SomeName" value="@i" id="SomeName_@i" checked>
}
else
{
<input type="checkbox" name="SomeName" value="@i" id="SomeName_@i">
}
<label for="SomeName_@i">@TestApp.Controllers.HomeController.enumFriendlyName[n]</label><br />
}
</div>