简体   繁体   中英

I cant get the visible properties of my panel ( 1 to 6 ) to change from false to true, they are contained within a loginview , can anyone help me

Partial Class Details
    Inherits System.Web.UI.Page
    Private Sub Hiding()
        Dim Panel1 As Panel
        Dim Panel2 As Panel
        Dim Panel3 As Panel
        Dim Panel4 As Panel
        Dim Panel5 As Panel
        Dim Panel6 As Panel
        Dim menu1 As Menu

        Panel1 = LoginView1.FindControl("Panel1")
        Panel2 = LoginView1.FindControl("Panel2")
        Panel3 = LoginView1.FindControl("Panel3")
        Panel4 = LoginView1.FindControl("Panel4")
        Panel5 = LoginView1.FindControl("Panel5")
        Panel6 = LoginView1.FindControl("Panel6")
        menu1 = LoginView1.FindControl("Menu1")

        Panel1.Visible = False
        Panel2.Visible = False
        Panel3.Visible = False
        Panel4.Visible = False
        Panel5.Visible = False
        Panel6.Visible = False
    End Sub

    Protected Sub Menu1_MenuItemClick(sender As Object, e As System.Web.UI.WebControls.MenuEventArgs)
        Dim Panel1 As Panel
        Dim Panel2 As Panel
        Dim Panel3 As Panel
        Dim Panel4 As Panel
        Dim Panel5 As Panel
        Dim Panel6 As Panel
        Dim menu1 As Menu


        Panel2 = LoginView1.FindControl("Panel2")
        Panel3 = LoginView1.FindControl("Panel3")
        Panel4 = LoginView1.FindControl("Panel4")
        Panel5 = LoginView1.FindControl("Panel5")
        Panel6 = LoginView1.FindControl("Panel6")
        menu1 = LoginView1.FindControl("Menu1")

        If menu1.ID = "Medical and Nursing MDT" Then
            Panel1 = LoginView1.FindControl("Panel1")
            Panel1.Visible = True
        ElseIf menu1.ID = "STACO" Then
            Call Hiding()
            Panel2.Visible = True
        ElseIf menu1.ID = "Infection alerts" Then
            Call Hiding()
            Panel3.Visible = True
        ElseIf menu1.ID = "Discharge and Health" Then
            Call Hiding()
            Panel4.Visible = True
        ElseIf menu1.ID = "Delays" Then
            Call Hiding()
            Panel5.Visible = True
        ElseIf menu1.ID = "Out of hours communcation" Then
            Panel6.Visible = True
        End If

    End Sub


End Class

try something like this... I know this code is raw but it may help you.

'declare local variables

Dim p1 As Panel
'search in the control tree for specific panel - Panel1 is the panel control name
Dim myControls As Control() = Me.Controls.Find("Panel1", False)
'direct cast and assign to local variable
p1 = DirectCast(myControls(0), Panel)

If (myControls.Length > 0) Then
'code for panel logic
End If

HTH - Nilesh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM