lorena Posted September 13, 2005 Posted September 13, 2005 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: 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. Quote
lorena Posted September 13, 2005 Author Posted September 13, 2005 P.S. - the boolean values are dimmed earlier in the code. This is the line that is erroring txtReqDate.Text = dtmDate.ToShortDateString Quote
Leaders snarfblam Posted September 13, 2005 Leaders Posted September 13, 2005 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. Quote [sIGPIC]e[/sIGPIC]
lorena Posted September 13, 2005 Author Posted September 13, 2005 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... Quote
Administrators PlausiblyDamp Posted September 13, 2005 Administrators Posted September 13, 2005 Which line is giving the error? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lorena Posted September 13, 2005 Author Posted September 13, 2005 txtReqDate.Text = dtmDate.ToShortDateString Quote
Administrators PlausiblyDamp Posted September 13, 2005 Administrators Posted September 13, 2005 (edited) If you step through in the debugger what is the value of txtReqDate? Edited April 4, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lorena Posted September 13, 2005 Author Posted September 13, 2005 Sorry - this was a programmer problem - not a control problem. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.