In VB.NET Button click event I am unable to set Visible = true. In all examples in the code below the Control visible property is set to False although the code is setting it to True? Does anyone know how to fix this. I tried setting all parent controls to visible.
Public Sub btnReports_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnReports.Click
If Not IsAllowed(_contextAppUser, btnReports) Then
Exit Sub
End If
ToggleMenuButtonSelection(btnReports, "idec_mainmenu_button")
RememberMenuSelection(Me, btnReports, (New StackFrame).GetMethod())
InitializeReportsView()
Dim Set1 As Boolean = True
If upnlMainMenu.Visible = False Then
upnlMainMenu.Visible = Set1
End If
Dim container As Control
Dim cntrl As Control = upnlMainMenu.FindControl("tvReportNavigation")
cntrl.Visible = True
If upnlMainMenu.Visible = False Then
upnlMainMenu.Visible = Set1
End If
If tblcellMainMenu.Visible = False Then
tblcellMainMenu.Visible = Set1
End If
If dgFileListing.Visible = False Then
dgFileListing.Visible = Set1
End If
If mvMainContent.Visible = False Then
mvMainContent.Visible = Set1
End If
If vwReports.Visible = False Then
vwReports.Visible = Set1
End If
If tvTrainerDocs.Visible = False Then
tvTrainerDocs.Visible = Set1
End If
If pnlReportNav.Visible = False Then
pnlReportNav.Visible = Set1
End If
If tvReportNavigation.Visible = False Then
tvReportNavigation.Visible = Set1
End If
If pnlFileListing.Visible = False Then
pnlFileListing.Visible = Set1
End If
If dgFileListing.Visible = False Then
dgFileListing.Visible = Set1
End If
Me.vwReports.Visible = True
Visible should be set to True.
cntrl
and assigning it a reference to an existing control. You declarecontainer
but never use it. I would extract all the code to change visibility of controls to a separate Sub, with a parameterisVisible
.ToggleMenuButtonSelection()
doing? Also, revise your question to clearly state the desired behavior. As of now, it just says what is happening and not what you want it to do.