首页 > 解决方案 > 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)

标签: htmlrazorasp.net-core-mvc

解决方案


推荐阅读