0
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
4

1 回答 1

0

尝试这样的事情......我知道这段代码是原始的,但它可能会对你有所帮助。

'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 - 尼莱什

于 2012-07-27T17:18:52.107 回答