[ASP.Net2] Object reference not set to an instance of an object.

W

WONG Chi Kit Keith

When the following script is processed, errors return:
Partial Class _Default
Inherits System.Web.UI.Page


Public Sub New()
Me.txtBox.Text = "This is a text box."
End Sub
End Class

Error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 5:
Line 6: Public Sub New()
Line 7: Me.txtBox.Text = "This is a text box."
Line 8: End Sub
Line 9: End Class

Source File: f:\inetpub\wwwroot\Default.aspx.vb Line: 7

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
_Default..ctor() in c:\inetpub\wwwroot\Default.aspx.vb:7
ASP.default_aspx..ctor() in c:\inetpub\wwwroot\Default.aspx.vb:912304
__ASP.FastObjectFactory_app_web_rzbiactk.Create_ASP_default_aspx() +38
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +115
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +139
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +120
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
 
K

Kevin Spencer

My first question would be, is there a textbox in the page? My second
question would be, is it named "txtBox"?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

When the following script is processed, errors return:
Partial Class _Default
Inherits System.Web.UI.Page


Public Sub New()
Me.txtBox.Text = "This is a text box."
End Sub
End Class

Error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 5:
Line 6: Public Sub New()
Line 7: Me.txtBox.Text = "This is a text box."
Line 8: End Sub
Line 9: End Class

Source File: f:\inetpub\wwwroot\Default.aspx.vb Line: 7

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
_Default..ctor() in c:\inetpub\wwwroot\Default.aspx.vb:7
ASP.default_aspx..ctor() in c:\inetpub\wwwroot\Default.aspx.vb:912304
__ASP.FastObjectFactory_app_web_rzbiactk.Create_ASP_default_aspx() +38
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +115
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
+40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
+139
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+120
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +155
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top