html - How to hide the asp-for label element if the value of displayfor element is empty?
问题描述
In my cshtml class for details, I do need to disable the label(asp-for) if the value of displayfor is empty.
@*For simplicity I put only part of the code as everything below is pretty much the same piece of code *@
<div align="center">
<div class="media-middle" style="width: 600px;">
<table class="table glyphicon-align-center">
<tbody>
<tr>
<th><label asp-for="StrainName"></label></th>
<td>@Html.DisplayFor(model => model.StrainName)</td>
</tr>
I would be thankful if someone gives me an idea about how to realize this code and where it is better to implement the code( cshtml class or in a controller)
解决方案
推荐阅读
- python - django 表单字段 error_messages 不适用于 IntegerField
- terraform - 使用 for_each 在 terraform 函数中使用列表/元组
- java - 删除特定对象后,数组列表中的对象被遗漏
- authentication - Google 如何跨多个平台/域与登录用户进行交流?
- java - kotlin/java 用正则表达式匹配字符串中的数字
- spring-security - spring security 自定义登录 - 如何使用 html 表单操作获取响应?
- c# - 我在 >NET Web API 中实现 MediatR 时遇到问题。我不知道发生了什么
- sql - BigQuery 时间戳显示 .9999
- eclipse - Eclipse:新建Java类向导:为什么不总是填入包?
- windows - 为什么批处理文件命令行参数在控制台中消失?