cysus
cysus

Reputation: 143

Find asp.net controls during a loop

In a asp.net vb code are several panels with ids like pnl_TN1, pnl_TN2, pnl_TN3, ..., pnl_TNx. The panels are all visible = false .

How can I iterate from i =2 to 4 with setting pnl_TNi visible to true?

Upvotes: 2

Views: 250

Answers (1)

pvzkch
pvzkch

Reputation: 341

You can use FindControl:

For i As Integer = 2 To 4
    Dim ctrl = Me.FindControl("pnl_TN" & i)
    If ctrl IsNot Nothing Then
        ctrl.Visible = True
    End If
Next

Upvotes: 2

Related Questions