المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Cross Page Postback



C# Programming
03-28-2009, 01:40 AM
I have two pages. Page A cross postbacks to Page B. On both pages I have a hidden field. I want to set Page B's hidden field with the value from Page A. The problem is that when it leaves Page A a value is in the hidden field. However when it Page B initializes (which is where I am checking the value and writing it to the new hidden field.) the value is an empty string. I have stepped through the code to make sure that when it leaves Page A there is a value and when it "arrives" Page B there is an empty string.

I cannot figure out why this is happening. Can anyone assist? Here are the pieces of my code:


protected void Page_Init(object sender, EventArgs e)
{
Page pg = PreviousPage;

if (pg != null)
{
HiddenField hfPrevStudent = Helpers.FindControl(pg, "hfStudent");
HiddenField hfPrevSchool = Helpers.FindControl(pg, "hfSchool");
if (hfPrevStudent != null)
{
hfStudent.Value = hfPrevStudent.Value;
hfSchool.Value = hfPrevSchool.Value;
}
}
}


~Candi