Home All Groups Group Topic Archive Search About

CrossPage Posting and the How Do I Webcast

Author
20 Mar 2006 9:27 PM
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
--
Application Engineer / DBA
UCLA SOM

Author
20 Mar 2006 10:57 PM
CaffieneRush@gmail.com
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.
Author
21 Mar 2006 12:11 AM
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.
--
Application Engineer / DBA
UCLA SOM


Show quoteHide quote
"CaffieneR***@gmail.com" wrote:

>  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.
>
>