我有一个问题,我有这个表,其中包含大量的信息,它们在线下等等,有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和顶部的线之间有一个很大的差距,那么它就在它的正下方。隐藏的第3张图片只有当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
}
答案 0 :(得分:2)
因此,当我在此处查看您的代码时,您似乎试图隐藏td
内的<tr>' yeah that worked it hides the
<td id=Extra but it doesnt hide the <tr
,因此请尝试隐藏&lt; tr>
<tr runat="server" id="Extra" >
<td align="center" ><img alt="" src="../images" style="height:80px" id="sign3" runat="server" /><br />
<asp:Label ID="lblUnderline3" runat="server" Text="____________________________"></asp:Label>
</td>
这将适用于您当前的动态条件
Extra.Visible = false;
Extra.Style.Add("display", "none");
Extra.Style.Add("width", "0px");Extra.Style.Add("height", "0px"); // Even this as your default height is 80px