gpt4 book ai didi

c# - 在 C# 中通过 ID 动态删除 标签

转载 作者:太空宇宙 更新时间:2023-11-04 01:28:22 25 4
gpt4 key购买 nike

我有一个问题,我有这张表,里面有一堆信息,它们有下划线等,有 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>

看起来像这样:

This image

如果您看到 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
}

最佳答案

因此,当我在这里查看您的代码时,您似乎正试图隐藏 td那是在 <tr>' yeah that worked it hides the
<td id=Extra but it doesnt hide the <tr
里面所以尝试隐藏 < 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

关于c# - 在 C# 中通过 ID 动态删除 <tr> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47580360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com