.Object reference not set to an instance of an object

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
Folks,


Hope you can help me here. I am getting a "System.NullReferenceException: Object reference not set to an instance of an object." type error

I have retrieved a variable from an external page using the following:

VB.NET:
[size=2][color=#0000ff]Public[/color][/size][size=2][color=#0000ff]Class[/color][/size][size=2] WebForm1[/size]
[size=2][color=#0000ff]Inherits[/color][/size][size=2] System.Web.UI.Page[/size]
[size=2][color=#0000ff]Protected WithEvents [/color][/size][size=2]amountLabel [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Web.UI.WebControls.Label[/size][size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] Page_Load([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2][color=#0000ff]MyBase[/color][/size][size=2].Load

[/size][size=2][color=#008000]' Retrieve Base Amount[/color][/size]
[size=2][color=#0000ff]If[/color][/size][size=2][color=#0000ff]Not[/color][/size][size=2] Request.QueryString.Item("BaseAmount") [/size][size=2][color=#0000ff]Is[/color][/size][size=2][color=#0000ff]Nothing[/color][/size][size=2][color=#0000ff]Then[/color][/size]
[size=2]baseAmount = Request.QueryString.Item("BaseAmount")
[/size][size=2][color=#0000ff]Else[/color][/size]
[size=2]   Response.Write("Unable to retrieve base amount")[/size]
[size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If[/color][/size]
[size=2][color=#0000ff][/color][/size] 
 
[size=2][color=#0000ff][size=2]amountLabel.Text = baseAmount
[/size][/color][/size]

I convert it to string and then assign to a label. This is all done in the code-behind file.

In the HTML front end I have:


HTML:
<asp:label id="amountLabel" runat="server"></asp:label>

I can compile but when I run it throws the error over the line:

amountLabel.Text = baseAmount

It does not like this fopr some reason. Anyone with any ideas?

Confused,
G.
 
Top Bottom