I followed the tutorial: Getting Public Property Values from the Source Page on MSDN and I started a fresh Web Forms site and created the below two pages. They work just fine. Now, if I copy paste these into my other Web Forms project then PreviousPage == null. I have no idea what the issue could be. There is no errors whatsoever. I just get
messageSTr.Text = "Not a cross-page post.";
UPDATE: I deleted the MasterPage reference in the page declaration and im still getting the error. I copied this projects web.config to the other working one and it still works. Its not my web config, I am at a complete loss here. This is a vital tool that I need for my application.
This page submits to page 1
<%@ Page
Title=""
Language="C#"
MasterPageFile="~/Site.Master"
AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs"
Inherits="WebApplication5.WebForm2" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<asp:Button id="button1" Text="Submit to PostBackUrl" PostBackUrl="~/WebForm1.aspx" runat="server"/>
This page receives the submit
<%@ Page
Title=""
Language="C#"
MasterPageFile="~/Site.Master"
AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication5.WebForm1" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<asp:Label ID="messageSTr" runat="server"></asp:Label>
WebForm1.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
if (PreviousPage.IsCrossPagePostBack == true)
{
messageSTr.Text = PreviousPage.imaliveStr;
}
}
else
{
messageSTr.Text = "Not a cross-page post.";
}
}