【发布时间】:2014-05-03 04:39:28
【问题描述】:
如果我的表格中没有返回任何结果,我会尝试隐藏按钮并显示文本。
如果我的桌子有什么,下面的代码:
<table class="stripped" id="table">
<tr>
<th>DB ID</th>
<th>
@Html.ActionLink("Environment", "Index", new { sortOrder = ViewBag.EnviroSortParam })
</th>
<th>
@Html.ActionLink("Product", "Index", new { sortOrder = ViewBag.ProductSortParam })
</th>
<th>
@Html.ActionLink("Test Type", "Index", new { sortOrder = ViewBag.TestTypeSortParam })
</th>
<th>
@Html.ActionLink("Scenario", "Index", new { sortOrder = ViewBag.ScenarioSortParam })
</th>
<th>
@Html.ActionLink("Times Run", "Index", new { sortOrder = ViewBag.TimesRunSortParam })
</th>
<th>
@Html.ActionLink("Failed Count", "Index", new { sortOrder = ViewBag.FailedCountSortParam })
</th>
<th>
@Html.ActionLink("Last 'Passed' Date", "Index", new { sortOrder = ViewBag.LastPassedDateParam })
</th>
<th>
@Html.ActionLink("Last 'Failed' Date", "Index", new { sortOrder = ViewBag.LastFailedDateParam })
</th>
<th>
Actions
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Environment)
</td>
<td>
@Html.DisplayFor(modelItem => item.Product)
</td>
<td>
@Html.DisplayFor(modelItem => item.TestType)
</td>
<td>
@Html.DisplayFor(modelItem => item.Scenario)
</td>
<td>
@Html.DisplayFor(modelItem => item.TimesRun)
</td>
<td>
@Html.DisplayFor(modelItem => item.FailedCount)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastPassedDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastFailedDate)
</td>
<td class="Link">
@if (item.LastFailedDate != null)
{
if (Convert.ToDateTime(item.LastFailedDate).Date == DateTime.Now.Date)
{
@Html.ActionLink("Show Details", "Details", new { id = item.Id })
<i class="fa fa-chevron-right"></i>
}
}
</td>
</tr>
}
下面的代码显示了我的导出按钮的代码:
<div class="RightAlign">
<button class="butstyle" id="Export" onclick="Export_Click" title="Click to export the results above as a CSV file.">
Export To Excel <i class="fa fa-table"></i>
</button>
</div>
正如我所说,如果没有找到结果,我希望隐藏按钮并显示以下内容:
<p id="NRF" class="NRF">No Test Runs Found.</p>
我该怎么做或者最好的方法是什么,因为我似乎无法理解它。我正在使用 HTML5 和 MVC5。
【问题讨论】:
标签: javascript jquery asp.net-mvc html asp.net-mvc-5