KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I add html to the page from inside an if() in a @foreach() . I get dont get any specific error it just does not take the second if() . It writes it out like text. this is what i tried but with no luck @foreach (var item in Model) { if (count % 4 == 0 || totaltCount == 1) { <div class="in-instructor-container"> } <div class="in-instructor"> <h3>@item.Name</h3> @item.Information </div> if ((count - 1) % 3 == 0 || count == totaltCount) { </div> } count++; } my html get like this <div class="in-instructor-container"> } <div class="in-instructor"> <h3>Test Person 0</h3> bla bla bla bla bla bla bla </div> if ((count - 1) % 3 == 0 || count == totaltCount) { </div>
Tags (comma-separated)
Save Edits
Cancel