T
tshad
I have an object that is my position table.
I set up a global variable like so:
Dim newPosition as New Position
My Page_Load and Page PreRender routines are:
*************************************************************
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
newPosition.JobTitle = "a new JobTitle"
JobTitle.Text = newPosition.JobTitle
trace.warn("newPosition = " & newPosition.JobTitle) <--
works
end if
newPosition = viewState("newPosition")
trace.warn("newPosition = " & newPosition.JobTitle) <--
doesn't work
end sub
Sub Page_PreRender(ByVal Sender As Object, ByVal E As EventArgs)
viewstate("newPosition") = newPosition
End Sub
**************************************************************
On the page back I get the error:
**************************************************************
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 36: end if
Line 37: newPosition = viewState("newPosition")
Line 38: trace.warn("newPosition = " & newPosition.JobTitle) <-- error
Line 39: end sub
Line 40:
****************************************************************************I thought you could put objects in the viewState?What about a session variable?Thanks,Tom
I set up a global variable like so:
Dim newPosition as New Position
My Page_Load and Page PreRender routines are:
*************************************************************
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
newPosition.JobTitle = "a new JobTitle"
JobTitle.Text = newPosition.JobTitle
trace.warn("newPosition = " & newPosition.JobTitle) <--
works
end if
newPosition = viewState("newPosition")
trace.warn("newPosition = " & newPosition.JobTitle) <--
doesn't work
end sub
Sub Page_PreRender(ByVal Sender As Object, ByVal E As EventArgs)
viewstate("newPosition") = newPosition
End Sub
**************************************************************
On the page back I get the error:
**************************************************************
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 36: end if
Line 37: newPosition = viewState("newPosition")
Line 38: trace.warn("newPosition = " & newPosition.JobTitle) <-- error
Line 39: end sub
Line 40:
****************************************************************************I thought you could put objects in the viewState?What about a session variable?Thanks,Tom