By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 1,866 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Object reference not set to an instance of an object.

P: 4
Hi,

I am new to VB .Net programming and is trying to create a webpage. I encountered the following error and is totally clueless on how to make it work:

==================ERROR=========================== =======
Object reference not set to an instance of an object.


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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
ICAPS_admin.WebForm1.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

================================================== =======

My webpage that I am trying to load is a very simple one which consist of only 3 dropdown list and 2 textbox. Below is my VB code:


==================Code ===================================
Expand|Select|Wrap|Line Numbers
  1. Public Class WebForm1
  2.     Inherits System.Web.UI.Page
  3.  
  4. #Region " Web Form Designer Generated Code "
  5.  
  6.     'This call is required by the Web Form Designer.
  7.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  8.  
  9.     End Sub
  10.     Protected WithEvents LabelSearchGemSecNo As System.Web.UI.WebControls.Label
  11.     Protected WithEvents txtBoxGemSecNo As System.Web.UI.WebControls.TextBox
  12.     Protected WithEvents LabelSearchUserID As System.Web.UI.WebControls.Label
  13.     Protected WithEvents txtBoxUserID As System.Web.UI.WebControls.TextBox
  14.     Protected WithEvents LabelStatus As System.Web.UI.WebControls.Label
  15.     Protected WithEvents LabelCAtype As System.Web.UI.WebControls.Label
  16.     Protected WithEvents LabelIndicator As System.Web.UI.WebControls.Label
  17.     Protected WithEvents ddlStatus As System.Web.UI.WebControls.DropDownList
  18.     Protected WithEvents ddlCAtype As System.Web.UI.WebControls.DropDownList
  19.     Protected WithEvents ddlIndicator As System.Web.UI.WebControls.DropDownList
  20.  
  21.     'NOTE: The following placeholder declaration is required by the Web Form Designer.
  22.     'Do not delete or move it.
  23.     Private designerPlaceholderDeclaration As System.Object
  24.  
  25.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  26.         'CODEGEN: This method call is required by the Web Form Designer
  27.         'Do not modify it using the code editor.
  28.         InitializeComponent()
  29.     End Sub
  30.  
  31. #End Region
  32.  
  33.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  34.         'Put user code to initialize the page here
  35.     End Sub
  36.  
  37.  
  38.     Private Sub ddlCAtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCAtype.SelectedIndexChanged
  39.  
  40.     End Sub
  41. End Class
  42.  
================================================== =======

Can anyone advise on this pls?

Thanks and regards,

livmacca
Mar 26 '08 #1
Share this Question
Share on Google+
4 Replies


balabaster
Expert 100+
P: 797
Put a breakpoint on the Page_Load event and run your web application. When the breakpoint is reached hit F11 to step through the application. What is the exact line of code executed when this error occurs?

I'm failing to see anything wrong with the code you provided - so if you've provided everything in your project, then I'm thinking that it's an environment problem. But I'd rather not tell you that your Visual Studio needs reinstalling - lord knows it takes long enough.
Mar 26 '08 #2

nev
100+
P: 251
nev
Check to see if anything being referenced is null or has valid data type.
Mar 26 '08 #3

Plater
Expert 5K+
P: 7,872
This is a VS2003 web application right? (In VS2005 you don't see the designer code like that)
Did you leave out any code? it looks like your page_load event is empty, but that's where it says the error is comming from?
Mar 26 '08 #4

P: 4
Put a breakpoint on the Page_Load event and run your web application. When the breakpoint is reached hit F11 to step through the application. What is the exact line of code executed when this error occurs?

I'm failing to see anything wrong with the code you provided - so if you've provided everything in your project, then I'm thinking that it's an environment problem. But I'd rather not tell you that your Visual Studio needs reinstalling - lord knows it takes long enough.


Hi,

I guess it is the environment issue as it went away after i reinstalled VS 2003. Thanks for your reply! :)
Mar 29 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.