//ResultPage.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ResultsPage.aspx.cs" Inherits="ResultsPage" %> <%@ PreviousPageType VirtualPath ="~/Default.aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> </div> <asp:Label ID="labelResult" runat="server" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" PostBackUrl="~/Default.aspx" Text="Button" /> </form> </body> </html>
//ResultPage.aspx.cs
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class ResultsPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { RegistrationInformation ri = PreviousPage.RegistrationInformation; labelResult.Text = string.Format("{0} {1} selected the event {2}", ri.firstName, ri.lastName, ri.selectedEvent); } catch { labelResult.Text = "The originating page must contain " + "textFirstname, textLastname, textEmail controls"; } } }
//RegistrationInformation.cs
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; /// <summary> /// Summary description for RegistrationInformation /// </summary> public struct RegistrationInformation { public string firstName { get; set; } public string lastName { get; set; } public string email { get; set; } public string selectedEvent { get; set; } }