CrossPage Posting and the How Do I Webcast

M

Marcial

The following code is supposed to allow me to capture some label.text values
from a preceeding page. I have placed a link button control on "source page"
and configured the PostbackUrl property to point to the "destination page".
On the destination page I would like to retrieve the text values from the
"source page" and use them as needed. This is the basic functionality of
Crosspage posting as I understand it.

However when I run the page and click the link button I am preented wtih an
error:

NullReference was unhandled by the user code.
Object reference not set to an instance of an object.

The code below was based on an ASP.NET 2.0 How Do I Vidoe Series: Tips and
Tricks. after viewin g the souce code and search a bit fro how to debugg it
I tried adding the New keyword declarations. However the error above
contiues to appear.

Now that i've exposed myself as the newbie that i am can someone explain the
obvious to me.

Thanks in advance!

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not Page.IsPostBack Then

Dim c As New Label
Dim s As New Label

c.Text = Nothing
s.Text = Nothing

c = CType(PreviousPage.FindControl("CaseCounterLabel1"), Label)
s = CType(PreviousPage.FindControl("lblSpecies"), Label)

lblCaseCounter.Text = String.Format("Case Number {0}", c.Text)
lblSp_Cd.Text = String.Format("Species {1}", s.Text)

End If
End Sub
 
C

CaffieneRush

lblSp_Cd.Text = String.Format("Species {1}", s.Text)
Should be
lblSp_Cd.Text = String.Format("Species {0}", s.Text)

Lookup String.Format in MSDN if you want more information.
 
M

Marcial

Unfortunately changing the {1} to [0} did not work.
I reviewed the String.format method and am still suffering from a mental
block on what step I'm missing.
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top