gpt4 book ai didi

html - 从 vb.net 代码端隐藏

转载 作者:太空狗 更新时间:2023-10-29 14:52:28 25 4
gpt4 key购买 nike

我有这段代码用于在后端 vb.net 的 aspx 中隐藏表格和单元格。代码-

For Each row As HtmlTableRow In tab_a1.Rows
If row.ID = "a1" Then
For Each cell As HtmlTableCell In row.Cells
cell.Visible = (cell.ID = "a1")
Next
ElseIf row.ID = "b1" Then
For Each cell As HtmlTableCell In row.Cells
cell.Visible = (cell.ID = "b1")
Next
Else
row.Visible = False
End If
Next

现在我使用 <div> 而不是表格标签。如何使用类似的代码使 div 可见和不可见?

最佳答案

runat="server" 和一个 ID 添加到您的 div。然后,您可以使用其 Visible 属性隐藏 div。

标记:

<div ID="myDiv" runat="server">Test DIV</div>

VB:

myDiv.Visible = False 'Hide the div.
myDiv.Visible = True 'Show the div.

您可以使用控件集合循环遍历子控件:

For Each child As Control In myDiv.Controls
If TypeOf child Is HtmlControl Then
Dim typedChild As HtmlControl = CType(child, HtmlControl)
'Search grandchildren, toggle visibility, etc.
End If
Next

关于html - 从 vb.net 代码端隐藏 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2694783/

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