P
Peter Kaufman
I am using the following code from ASP.NET Unleashed successfully in
an aspx page, but when I move it to a code behind page in VS I get
this error on the asterisked line when the code runs :
Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnNextPage.Click
Dim pnlPanel As panel
Dim strPanelName As String
' Hide Previous Panel
strPanelName = "pnlForm" & ViewState("CurrentPage")
*pnlPanel = FindControl( strPanelName )
pnlPanel.Visible = False
End Sub
System.InvalidCastException: Specified cast is not valid
Line 65: pnlPanel = FindControl(strPanelName)
strPanelName is resolving to the string "pnlForm1".
I also tried: pnlPanel = CType(FindControl(strPanelName), panel) -got
the same error
Help appreciated!
Peter
an aspx page, but when I move it to a code behind page in VS I get
this error on the asterisked line when the code runs :
Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnNextPage.Click
Dim pnlPanel As panel
Dim strPanelName As String
' Hide Previous Panel
strPanelName = "pnlForm" & ViewState("CurrentPage")
*pnlPanel = FindControl( strPanelName )
pnlPanel.Visible = False
End Sub
System.InvalidCastException: Specified cast is not valid
Line 65: pnlPanel = FindControl(strPanelName)
strPanelName is resolving to the string "pnlForm1".
I also tried: pnlPanel = CType(FindControl(strPanelName), panel) -got
the same error
Help appreciated!
Peter