开发者

Hiding <div> from vb.net code side

开发者 https://www.devze.com 2022-12-28 01:37 出处:网络
I have this code for hiding a table and a cell in aspx, backend vb.net. Code - For Each row As HtmlTableRow In tab_a1.Rows

I have this code for hiding a table and a cell in aspx, backend vb.net. Code -

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 HtmlTable开发者_如何学GoCell In row.Cells
                            cell.Visible = (cell.ID = "b1")
                        Next
                    Else
                        row.Visible = False
                    End If
                Next

Now instead of tables I'm using <div> tags. How can I use similar code and make div's visible and invisible?


Add runat="server" and an ID to your div. You can then hide the div using its Visible property.

Markup:

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

VB:

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

You can loop through child controls using the controls collection:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消