.NETGURU
Object reference not set..
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.


Damian Barrow
Anyone see what I'm doing wrong here?

I'm using a control (ships.ascx) on my page and I pass to it the value
of the parent page.

So - parentpage (pando.aspx in this case)

<%@ Page Language=3D"vb" Explicit=3D"True" EnableSessionState=3D"True"
smartnavigation=3D"True" Strict=3D"True" %>
<%@ Register TagPrefix=3D"showShips" tagName=3D"shipsBit"
src=3D"/cruise/ships.ascx" %>
<%@ import Namespace=3D"System.Data" %>
<%@ import Namespace=3D"System.Data.SqlClient" %>

<script language=3D"VB" runat=3D"server">

Public Sub Page_Load(Sender as Object, E as EventArgs)
Dim strPP as String =3D "pando.aspx"
myShips.parentPage =3D strPP

If Not Page.IsPostBack Then

BindGrid()

' ######################## etc etc etc..........
</script>

Blah

<showShips:shipsBit id=3D"myShips" runat=3D"server" />

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And the ships.ascx is

<%@ Control Language=3D"vb" %>
<%@ import Namespace=3D"System.Data" %>
<%@ import Namespace=3D"System.Data.SQLClient" %>
<%@ outputcache duration=3D"1800" varybyparam=3D"None" %>

<script runat=3D"server" language=3D"VB">
Public Writeonly Property parentPage as String
    Set=20
        txt_parentPage.Text =3D value
    End Set
End Property
</script>
<asp:label id=3D"txt_parentPage" runat=3D"server"
Visible=3D"false"></asp:label>

Etc

When I pass the value it says:
Object reference not set to an instance of an object.=20
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.=20

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:=20

Line 12: Public Sub Page_Load(Sender as Object, E as EventArgs)
Line 13: Dim strPP as String =3D "pando.aspx"
Line 14: myShips.parentPage =3D strPP
Line 15:=20
Line 16:     if request.QueryString("sm")<>"FALSE" THEN=20

Help?!
Cheers
Damian

Reply to this message...
 
    
Daniel Naumann
Damian,

From your code snippet you haven't declared what "myships" is. Do you have
Option Explicit on? You should, this will pick up any undeclared variables.

You need something like:
Dim myships as ships

Daniel.

-----Original Message-----
From: Damian Barrow [mailto:Click here to reveal e-mail address]
Sent: 26-Jul-2002 08:25
To: aspngreuse
Subject: [aspngreuse] Object reference not set..

Anyone see what I'm doing wrong here?

I'm using a control (ships.ascx) on my page and I pass to it the value
of the parent page.

So - parentpage (pando.aspx in this case)

<%@ Page Language="vb" Explicit="True" EnableSessionState="True"
smartnavigation="True" Strict="True" %>
<%@ Register TagPrefix="showShips" tagName="shipsBit"
src="/cruise/ships.ascx" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">

Public Sub Page_Load(Sender as Object, E as EventArgs)
Dim strPP as String = "pando.aspx"
myShips.parentPage = strPP

If Not Page.IsPostBack Then

BindGrid()

' ######################## etc etc etc..........
</script>

Blah

<showShips:shipsBit id="myShips" runat="server" />

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And the ships.ascx is

<%@ Control Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SQLClient" %>
<%@ outputcache duration="1800" varybyparam="None" %>

<script runat="server" language="VB">
Public Writeonly Property parentPage as String
    Set
        txt_parentPage.Text = value
    End Set
End Property
</script>
<asp:label id="txt_parentPage" runat="server"
Visible="false"></asp:label>

Etc

When I pass the value it says:
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 12: Public Sub Page_Load(Sender as Object, E as EventArgs)
Line 13: Dim strPP as String = "pando.aspx"
Line 14: myShips.parentPage = strPP
Line 15:
Line 16:     if request.QueryString("sm")<>"FALSE" THEN

Help?!
Cheers
Damian

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT
Reply to this message...
 
 
System.EventArgs
System.NullReferenceException
System.Web.UI.Page




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification