からページにpartialviewまたはビュー内の奇数と偶数vlaue alternativeltyを印刷する方法を私は左側の画像&コンテンツのため、右側の画像&コンテンツのための2つのhtmlを持っています。モデルからの価値の高い印刷物。私はfor-eachループで書くことができ、Modelからページの部分ビューで奇数と偶数の値を交互に出力することができます。
@inherits UmbracoViewPage<List<ProjectName.Models.DealerSectionModel>>
@using ProjectName.Models;
@using Umbraco.Core;
@{
foreach (DealerSectionModel historylist in Model) // what should i write in this loop .(ex if 1 value in model then print odd html)
{
if()
{
@RenderEvenHistoryList(historylist)
}
else
{
@RenderOddHistoryList(historylist)
}
}
}
@helper RenderOddHistoryList(DealerSectionModel item)
{
<div class="row history-second-section py-2 py-xl-4 py-lg-4 py-md-4 py-sm-2">
<div class="col-12 col-xl-6 col-lg-6 col-md-6 col-sm-12 history-second-images">
<div class="quote my-3"><iframe src="@item.VideoUrl" width="510" height="282" frameborder="0" allowfullscreen></iframe></div>
</div>
<div class="col-12 col-xl-6 col-lg-6 col-md-6 col-sm-12 history-second-content">
<div class="content-year">@item.Title </div>
<h4>@item.ImageTitle</h4>
<p>@item.ImageDescription</p>
</div>
</div>
}
}
@helper RenderEvenHistoryList(DealerSectionModel item)
{
// render html for even model value
}
}
感謝! –