Mega Code Archive
The target page binds to the previous-page class type
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="DefaultWithType"%>
Cross-page posting with type information
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DefaultWithType : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
MultiView1.ActiveViewIndex = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Msg.Text = String.Format("Congratulations! You're going to {0}", DropDownList1.SelectedItem.Text);
MultiView1.ActiveViewIndex = 1;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
public DropDownList DropDownList1
{
get { return dropDownList1; }
}
public TextBox TextBox1
{
get { return textBox1; }
}
}
File: NextPage.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NextPage.aspx.cs"
Inherits="NextPage" %>
<%@ PreviousPageType VirtualPath="Default.aspx" %>
Welcome to the guru's page
File: NextPage.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class NextPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage == null)
{
Response.Write("Sorry, you can only invoke me through cross-page posting.");
Response.End();
return;
}
string action = PreviousPage.DropDownList1.SelectedItem.Text;
GuruAction.Text = action;
GuruName.Text = PreviousPage.TextBox1.Text;
}
}