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

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 partial class CrossPage1 : System.Web.UI.Page
{
        public string GetBankCardInfo()
        {
          return txtCardType.Text+” “+txtCardNumber.Text+” “+txtCardExpDate.Text;
        }
}

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

public partial class CrossPage2: System.Web.UI.Page
{
        protected void Page_Load(object sender, EventArgs e)
        {
          if ( PreviousPage != null )
          {
            CrossPage1 prevPage = (CrossPage1)(new PreviousPage());
            if ( prevPage != null )
            {
              lblCardInfo.Text  += “You entered this “ + prevPage.GetBankCardInfo();
            }
          }
        }
}