<asp:Button ID="btnSubmit" runat="server" Text="Submit" PostBackUrl="~/ShowContactData.aspx" />And the following code on the 2nd page (ShowContactData.aspx.cs):
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Program2 { public partial class ShowContactData : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { // Create an instance of the previous page's controls. TextBox firstName = null; TextBox lastName = null; // Fill variables with the values in the previous page using FindControl() of PreviousPage. firstName = (TextBox)this.PreviousPage.FindControl("txtFirstName"); lastName = (TextBox)this.PreviousPage.FindControl("txtLastName"); // Bind the labels using values in textboxes. lblFirstName.Text = firstName; lblLastName.Text = lastName; } } } }These are the labels on the ShowContactData.aspx page:
<asp:Label ID="lblFirstName" runat="server"></asp:Label> <br /> <asp:Label ID="lblLastName" runat="server"></asp:Label>