我有这个代码用于在aspx,后端vb.net中隐藏表和单元格.
代码 –
代码 –
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
解决方法
将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