【发布时间】:2018-03-27 11:49:23
【问题描述】:
我有这个:
@model IEnumerable<MVPTracker.Models.DashboardResult>
@using MVPTracker.Models;
@{
int row = 0;
ViewBag.Title = "DashboardList";
Layout = "~/Views/Shared/_Layout.cshtml";
string top = "<div class='row'> ";
string Bot = "</div> ";
}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="wrapper wrapper-content animated fadeInRight">
@{
foreach (var item in Model)
{
if (row == 0)
{
Html.Encode(top);
}
<div class="col-md-3">
<div class="ibox">
<div class="ibox-content product-box">
<div class="product-imitation">
<img src="~/Images/App/EventHeader.jpg" width="100%" />
</div>
<div class="product-desc">
<span class="product-price">
@Html.DisplayFor(modelItem => item.Sport.Name)
</span>
<a href="@Url.Action("ViewResults", "Results", new { key = Functions.encrypt(item.DashboardResultID.ToString()) })" class="product-name"> @Html.DisplayFor(modelItem => item.EventName)</a>
<div class="small m-t-xs">
<strong>Desc:</strong> @Html.DisplayFor(modelItem => item.Description) <br />
<strong>Date:</strong> @Html.DisplayFor(modelItem => item.EventDate)
</div>
<br />
<div class="m-t text-righ">
<a href="@Url.Action("UploadResults", "Results", new { key = Functions.encrypt(item.DashboardResultID.ToString()) })" class="btn btn-xs btn-outline btn-primary">Upload Results <i class="fa fa-long-arrow-right"></i> </a>
<a href="@Url.Action("ViewResults", "Results", new { key = Functions.encrypt(item.DashboardResultID.ToString()) })" class="btn btn-xs btn-outline btn-primary">View Results <i class="fa fa-long-arrow-right"></i> </a>
</div>
</div>
</div>
</div>
</div>
if (row == 3)
{
Html.Encode(Bot);
row = 0;
}
else
{
row++;
}
}
}
</div>
</div>
</div>
</div>
</div>
我有 2 个具有 div sn-p 的变量,当行已满时,我必须打印打开的 div 和关闭 div,而实际代码我做不到,我尝试了另一种东西(HTMLString,HTML.Raw ...) 但没有任何效果,您能帮我解决这个问题吗?
谢谢!
【问题讨论】:
-
你想做什么?你试过什么? (这无济于事“我尝试其他东西(HTMLString,HTML.Raw ...)坚果没有任何作用”))
-
在代码的顶部我有这个: string top = "";和字符串 Bot = "";我如何将其转换为 HTML,我尝试使用 HTML.Raw(top) 和 HTML.Encode(Top) 但没有@Shyju
-
您想按原样打印还是将该 HTML 呈现到页面中?
-
我想将该 HTML 呈现到页面中。
-
这是哪个 .net 版本? .net 核心?还是别的什么?
标签: html asp.net asp.net-mvc razor