未能找到类型或命名空间名称“ServerTransfer01
ServerTransfer01是上一页面的名称,可不可以用前一页面来定义变量?
ServerTransfer01 frmSource;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
frmSource = (ServerTransfer01)(HttpContext.Current.Handler);
NameValueCollection data = frmSource.TicketData;
txtTrainNumber.Text = data["txtTrainNumber"];
txtStartStation.Text = data["txtStartStation"];
txtEndStation.Text = data["txtEndStation"];
txtBookDate.Text = data["txtBookDate"];
txtStudentId.Text = data["txtStudentId"];
txtPhone.Text = data["txtPhone"];
txtRemark.Text = data["txtRemark"];
LblTrainNumber.Text = frmSource.TrainNumber;
LblStartStation.Text = frmSource.StartStation;
LblEndStation.Text = frmSource.EndStation;
LblBookDate.Text = Convert.ToString(frmSource.BookDate);
LblStudentId.Text = Convert.ToString(frmSource.StudentId);
LblPhone.Text = frmSource.Phone;
LblRemark.Text = frmSource.Remark;
}
}
------解决方案--------------------
因为它也是对象,每个对象都可以初始化,只要有构造函数都行