|
 |
aspx thread: Variable scope question.
Message #1 by "Oliver, Wells" <WOliver@l...> on Thu, 29 Aug 2002 14:24:14 -0700
|
|
I have a page class 'viewReport'.
I need a label -- 'requestorEmail' to be a globally accessible label, such
that one subroutine can set its text property and another read it.
I am working like so:
Public class viewReport
Inherits System.Web.UI.Page
Dim requestorEmail as Label
Private Sub Page_Load (S as System.Object, E as System.EventArgs)
Me.requestorEmail.Text = "Test"
End Sub
Public Sub SetEmail (S as System.Object, E as System.EventArgs)
Dim forwardAddress as Label
forwardAddress = Me.requestorEmail.Text
End Sub
End Class
This example results in the error "Object reference not set to an instance
of an object" within the SetEmail routine.
Any tips/information? Thank you.
Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com
Message #2 by Imar Spaanjaars <Imar@S...> on Thu, 29 Aug 2002 23:37:36 +0200
|
|
Hi there,
I think that this is causing the problem:
Dim forwardAddress as Label
forwardAddress = Me.requestorEmail.Text
You declare a new Label, but don't create it (using New).
Where is the label forwardAddress defined? On the ASPX page? Or is this a
dynamically generated control?
If so, change it to:
Dim forwardAddress as Label = New Label
Also, change:
forwardAddress = Me.requestorEmail.Text
to
forwardAddress.Text = Me.requestorEmail.Text
because right now you are assigning a string (requestorEmail.Text) to an
object of type Label.
HtH
Imar
At 02:24 PM 8/29/2002 -0700, you wrote:
>I have a page class 'viewReport'.
>
>I need a label -- 'requestorEmail' to be a globally accessible label, such
>that one subroutine can set its text property and another read it.
>
>I am working like so:
>
>Public class viewReport
> Inherits System.Web.UI.Page
>
> Dim requestorEmail as Label
>
> Private Sub Page_Load (S as System.Object, E as System.EventArgs)
> Me.requestorEmail.Text = "Test"
> End Sub
>
> Public Sub SetEmail (S as System.Object, E as System.EventArgs)
> Dim forwardAddress as Label
>
> forwardAddress = Me.requestorEmail.Text
> End Sub
>End Class
>
>This example results in the error "Object reference not set to an instance
>of an object" within the SetEmail routine.
>
>Any tips/information? Thank you.
>
>Wells Oliver
>Web Application Programmer
>Leviton Voice & Data
>xxx-xxx-xxxx
>http://www.levitonvoicedata.com
Message #3 by "Oliver, Wells" <WOliver@l...> on Thu, 29 Aug 2002 14:41:04 -0700
|
|
Ah, yes. Thanks, you are always a help!
-----Original Message-----
From: Imar Spaanjaars [mailto:Imar@S...]
Sent: Thursday, August 29, 2002 2:38 PM
To: ASP+
Subject: [aspx] Re: Variable scope question.
Hi there,
I think that this is causing the problem:
Dim forwardAddress as Label
forwardAddress = Me.requestorEmail.Text
You declare a new Label, but don't create it (using New).
Where is the label forwardAddress defined? On the ASPX page? Or is this a
dynamically generated control?
If so, change it to:
Dim forwardAddress as Label = New Label
Also, change:
forwardAddress = Me.requestorEmail.Text
to
forwardAddress.Text = Me.requestorEmail.Text
because right now you are assigning a string (requestorEmail.Text) to an
object of type Label.
HtH
Imar
At 02:24 PM 8/29/2002 -0700, you wrote:
>I have a page class 'viewReport'.
>
>I need a label -- 'requestorEmail' to be a globally accessible label,
>such that one subroutine can set its text property and another read it.
>
>I am working like so:
>
>Public class viewReport
> Inherits System.Web.UI.Page
>
> Dim requestorEmail as Label
>
> Private Sub Page_Load (S as System.Object, E as System.EventArgs)
> Me.requestorEmail.Text = "Test"
> End Sub
>
> Public Sub SetEmail (S as System.Object, E as System.EventArgs)
> Dim forwardAddress as Label
>
> forwardAddress = Me.requestorEmail.Text
> End Sub
>End Class
>
>This example results in the error "Object reference not set to an
>instance of an object" within the SetEmail routine.
>
>Any tips/information? Thank you.
>
>Wells Oliver
>Web Application Programmer
>Leviton Voice & Data
>xxx-xxx-xxxx
>http://www.levitonvoicedata.com
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
Message #4 by "Mike Amundsen" <mike@a...> on Thu, 29 Aug 2002 17:42:04 -0400
|
|
Globally reachable data must be stored in places such as:
SessionState, Cookies, Database
MCA
Mike Amundsen
mca@E...
host your .NET Apps @ EraServer.NET
-----Original Message-----
From: Oliver, Wells [mailto:WOliver@l...]
Sent: Thursday, August 29, 2002 5:24 PM
To: ASP+
Subject: [aspx] Variable scope question.
I have a page class 'viewReport'.
I need a label -- 'requestorEmail' to be a globally accessible label,
such
that one subroutine can set its text property and another read it.
I am working like so:
Public class viewReport
Inherits System.Web.UI.Page
Dim requestorEmail as Label
Private Sub Page_Load (S as System.Object, E as
System.EventArgs)
Me.requestorEmail.Text = "Test"
End Sub
Public Sub SetEmail (S as System.Object, E as System.EventArgs)
Dim forwardAddress as Label
forwardAddress = Me.requestorEmail.Text
End Sub
End Class
This example results in the error "Object reference not set to an
instance
of an object" within the SetEmail routine.
Any tips/information? Thank you.
Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
|
|
 |