html – 隐藏在vb.net代码端

前端之家收集整理的这篇文章主要介绍了html – 隐藏在vb.net代码端前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个代码用于在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

而不是我正在使用的表< 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/242666.html

猜你在找的HTML相关文章