Dear all
I am totally new to ASP.NET and I am trying to follow some examples from a book I have bought. However i have encountered the following error:-
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 56: strPanelName = "pnlForm" & ViewState("CurrentPage")
Line 57: pnlPanel = FindControl(strPanelName)
Line 58: pnlPanel.Visible = True
Line 59:
Line 60: End Sub
Source File: C:\Inetpub\ .aspx.vb Line: 58
Here is my code for this section:-
Sub btnNextPage_Click(ByVal s As Object, ByVal e As EventArgs)
Dim pnlPanel As Panel
Dim strPanelName As String
'Hide Previous Panel
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = False
'Show current Panel
ViewState("CurrentPage") += 1
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = True
End Sub
Can you please help me out?
Thanks
I am totally new to ASP.NET and I am trying to follow some examples from a book I have bought. However i have encountered the following error:-
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 56: strPanelName = "pnlForm" & ViewState("CurrentPage")
Line 57: pnlPanel = FindControl(strPanelName)
Line 58: pnlPanel.Visible = True
Line 59:
Line 60: End Sub
Source File: C:\Inetpub\ .aspx.vb Line: 58
Here is my code for this section:-
Sub btnNextPage_Click(ByVal s As Object, ByVal e As EventArgs)
Dim pnlPanel As Panel
Dim strPanelName As String
'Hide Previous Panel
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = False
'Show current Panel
ViewState("CurrentPage") += 1
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = True
End Sub
Can you please help me out?
Thanks