【发布时间】:2018-05-14 18:57:24
【问题描述】:
我有一个问题,我有这张表,里面有一堆信息,它们在线条等下面有 3 张图像,它们取决于某些条件等。代码如下:
<table id="Table1" cellspacing="1" cellpadding="1" width="661" border="0" class="auto-style3">
<tr>
<td align="center"><img alt="" src="../images" id="sign1" runat="server" style="height:80px" />
<asp:Label ID="lblUnderline1" runat="server" Text="____________________________"></asp:Label>
</td>
<td align="center"><img alt="" src="../images/" id="sign2" runat="server" style="height:80px" />
<asp:Label ID="lblUnderline2" runat="server" Text="____________________________"></asp:Label>
</td>
</tr>
<tr>
<td align="center" runat="server" id="Extra"><img alt="" src="../images" style="height:80px" id="sign3" runat="server" /><br />
<asp:Label ID="lblUnderline3" runat="server" Text="____________________________"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblTitle1" runat="server" Text="Vice President"></asp:Label>
</td>
<td align="center">
<asp:Label ID="lblTitle2" runat="server" Text=" Registrar"></asp:Label>
</td>
</tr>
</table>
看起来像这样:
如果您发现 Sign1 与顶部的线之间存在很大的差距,那么它假设就在下方。隐藏的第三张图片只有在 if 语句显示 If(This condition){sign3.visible =true 时才会出现但是行和标题之间的差距并没有消失我试过这个:
// Extra is the <tr> ID
Extra.Visible = false; Extra.Style.Add("display", "none");
Extra.Style.Add("width", "0px");
那么有没有办法在诸如
之类的 if 条件下从 c# 中将整个标签从 HTML 中删除 If(Condition This)
{
// Remove the <tr> Tag along the image in it
}
【问题讨论】:
-
我的建议是向您要隐藏的 TR 添加一个独特的类,然后在您的 css 文件中为该 TR 添加样式。现在,看起来 TR 默认的高度为 80 像素,您永远不会删除它。如果您不想创建/修改 css 样式表,则需要添加 Extra.Style.Add("height","0px");
-
我添加了你提到的高样式也不起作用,然后我删除了默认的 80px 它不起作用
标签: c# css asp.net html-table