<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="Default" %>
<%@ PreviousPageType VirtualPath="NextPage.aspx" %>
Using Server.Transfer
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.HtmlControls;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
MultiView1.ActiveViewIndex = 0;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Msg.Text = String.Format("You're going to {0}", DropDownList1.SelectedItem.Text);
MultiView1.ActiveViewIndex = 1;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("NextPage.aspx");
}
}
File: NextPage.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NextPage.aspx.cs"
Inherits="Default"%>
Target 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 Default : 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 or Server.Transfer.");
Response.End();
return;
} else {
if (PreviousPage.IsCrossPagePostBack)
Response.Write("The page is being invoked through cross-page posting");
}
DropDownList dd = (DropDownList)PreviousPage.FindControl("DropDownList1");
string action = dd.SelectedItem.Text;
GuruAction.Text = action;
TextBox txt = (TextBox)PreviousPage.FindControl("TextBox1");
GuruName.Text = txt.Text;
}
}