473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Object not working on pageback

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

Nov 19 '05 #1
1 1120
I found that this is only a problem with viewState.

If I put it in a session variable, like so:

session("newPosition") = newPosition
newPosition = session("newPosition")

it seems to work fine (as long as I mark the object as Serializable).

Why won't it work in viewState?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uB**************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Simon Strandgaard | last post by:
There are no <iframe> tag in xhtml strict, instead I should use <object>. If I change <iframe> to <object> then my javascript stops working. I am curious to how to use <object> with javascript...
0
by: Ian Pilcher | last post by:
Howdy all! I'm working with XML schemas for the first time, so please be gentle! I am working on a graphics program (in Java if it matters), and I have decided to use XML files to store the...
9
by: Tom | last post by:
I am working with the this object as oppose to the StreamReader object becuase I need to access a file (to find the contents) while an external application is updating the file. When I was...
2
by: Desmond | last post by:
Hi, I would really appreciate if somebody could give some advise on this. I've a ASP.NET application that is supposed to send emails and it is tested to be working well on IIS 5.0 and tested...
7
by: J-T | last post by:
I can instantiate my object in my *ASP.NET* application in two ways: A) public sealed class RSSingleton { private static ReportingServiceProxy m_RsProxy=null; static RSSingleton() {...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
1
by: jsgough | last post by:
Hello, I was writing some code using ASP.NET 2.0 that consumed a COM library via interop on Friday and everything was working fine until about thirty minutes before I left for the day (isn't it...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.