How to transfer information between pages in ASP.NET using cross-page posting in VB.NET

Software developer can transfer information between pages with technique named cross-page posting. If he wants to do use it he has to define specific, limited methods that extract just the information he need it.   Let’s for example he have a page with text boxes as controls for credit card. In this case software developer might decide to add a GetBankCardInfo() method that retrieves the information from text boxes:

Public Class CrossPage1
      Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

          ‘….

        End Sub

        Public Function GetBankCardInfo() As String
          Return txtCardType.Text + txtCardNumber.Text + txtCardExpDate.Text
        End Function

End Class

In the second page which retrieves information from Page1 the Page_Load event has the following code-behind:

Public Class CrossPage2
      Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          If Not IsNothing(PreviousPage) Then
            Dim PrevPg As CrossPage1 = New CrossPage1()
              If Not IsNothing(PrevPg) Then
                lblCardInfo.Text = lblCardInfo.Text + PrevPg.GetBankCardInfo()
              End If
            End If
        End Sub
End Class