I have been trying to get a variable to hold previous page content. I have been able to get this to work as long as I pass the CurrentUser and CurrentPass to a text box and then use that info from there. So, I've been hiding text boxes in my page to make this work. I don't understand why I can't just place these previous page variables into newly defined variables on this page.

I have tried a couple of different things but I keep getting the error message:

Error 1 An object reference is required for the nonstatic field, method, or property 'userpage.PreviousPage.get' C:\Inetpub\wwwroot\ThisTest\userpage.aspx.cs 15 30 C:\...\ThisTest\



The sample of one of my ideas:


static string crrntUsr = PreviousPage.CurrentUser.ToString();
static string crrntPss = PreviousPage.CurrentPass.ToString();


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Get the user name from the login page
crrntUsr = PreviousPage.CurrentUser;
//Get the password from the login page
crrntPss = PreviousPage.CurrentPass;
//Write out the usr and pass to textbox
//Label1.Text = PreviousPage.CurrentUser + PreviousPage.CurrentPass;
Label1.Text = crrntUsr + crrntPss;
//Label2.Text = PreviousPage.CurrentUser;
//Label3.Text = PreviousPage.CurrentPass;

while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();

if (Label2.Text == usr)
{
if (Label3.Text == pss)



Putting it directly into a text box and then going on with code using labels are fine. But I don't want to use hidden text boxes and labels, I was hoping someone could help me understand why I am not able to use variables to work with the previous page data.

My .aspx page has this directive:

<%@ PreviousPageType VirtualPath="login.aspx" %>



My previous pages .aspxcs has this code in it too:

public String CurrentUser
{
get
{
return userTxtbx.Text;
}
}
public String CurrentPass
{
get
{
return psswrdTxtbx.Text;
}
}



Thank you so much in advance.