The twist being, all answers that I found on the topic simply do not seem to work. I tried just about all formattings I found in answers to this question and made a few desperate attempts on my own, but none of them have any effect. It's almost as if razor wasn't there, but other razor synthax in the same cshtml file executes without trouble. As most of the time, the div is declared in a loop and its name should be appended by i. Here's some things I tried, not in the order I tried them in. The order can be deduced by the decreasing sanity of the synthax:
<div id="accord@(i)">
<div id="@("accord" + i)>
<div id="@{@("accord" + i)}">
with:
string fName = "accord" + i; //fName is filled correctly, that much I could verify
I tried some things:
<div id=@fName>
<div id="@fName">
<div id="@(fName)">
<div id="@{fName}">
<div id=@(fName)>
<div id="@{@fName}">
<div id=@{@fName}>
I also tried several combinations of the two approaches, like for example
string fName = "accord";
<div id="@(fName + i)">
aso...
All of these attempts have not yielded any results... the id of the div is ALWAYS #Literaly_Whatever_Comes_after_=
So... can anybody venture a guess at what I'm doing wrong?
In the interest of completion, since you never know what might be involved, here's the entire loop. It doesn't have any actual logic in it, that comes after I made the concept work:
<div id="yearaccord">
@for (int i = 0; i < 4; ++i)
{
//add a nested months accordion for every year
<h3>i = @i</h3>
string fName = "accord" + i;
<div id="@{@fName}">
@for (int j = 0; j < 4; ++j)
{
//add an accordion displaying the blog titles for each month
<h3>j = @j</h3>
<div>
@for (int w = 0; w < 6; ++w)
{
//add blog titles
<h4>JabbadaJba @w</h4>
}
</div>
}
</div>
}
</div>
Note that ALL other razor synthax in this loop behaves the way I expected it to... only when it's used as an id, things go wonky.