Help With Error Message

lorena

Centurion
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I recently installed Visual Studio 2003 upgrade and made sure that the .net framework on my computer has been upgraded too.
Now the .aspx page I am working on is giving me a "System.NullReferenceException: Object reference not set to an instance of an object" error.
Here is my code:
Visual Basic:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Dim dtmDate As Date
    dtmDate = DateTime.Now

    txtReqDate.Text = dtmDate.ToShortDateString
    success = True
    added = True
  End Sub
It worked in the previous version of Visual Studio.
Any ideas as to why this is happening? I would appreciate any help.
 
P.S. - the boolean values are dimmed earlier in the code.
This is the line that is erroring
Visual Basic:
txtReqDate.Text = dtmDate.ToShortDateString
 
I don't know much of anything about asp, but since dtmDate is clearly declared and assigned an object the only other reference in that line that could be null would be txtReqDate. Is the MyBase.Load event fired before the controls are created? If so then that would explain a NullReferenceException, and if not, I would be awefully confused.
 
I don't understand why this worked in the old version of VS.Net and not in the new version. I tried searching the MSDN KB but couldn't find anything. *sigh* Their search leaves alot to be desired...
 
Back
Top