day6.2
1.在ResultPage中添加:<%@ PreviousPageType VirtualPath="~/Registration.aspx" %>
这样之前ResultPage.aspx.cs中页面载入时间的代码则由:
1 try
2 {
3 DropDownList dropDownListEvents = (DropDownList)PreviousPage.FindControl("dropDownListEvents");
4 string selectedEvent = dropDownListEvents.SelectedValue;
5
6 string fistName = ((TextBox)PreviousPage.FindControl("textFirstName")).Text;
7
8 string lastName = ((TextBox)PreviousPage.FindControl("textLastName")).Text;
9
10 string email = ((TextBox)PreviousPage.FindControl("textEmail")).Text;
11
12 labelResult.Text = String.Format("{0} {1} selected the event {2}", fistName, lastName, selectedEvent);
13 }
14 catch
15 {
16 labelResult.Text = "The originating page must contain" + "textFirstName, textLastName, textEmail controls";
17 }
变为:
1 try
2 {
3 RegistrationInfo ri = PreviousPage.RegistrationInfo;
4 labelResult.Text = String.Format("{0} {1} selected the event {2}", ri.FirstName, ri.LastName, ri.SelectedEvent);
5 }
6 catch
7 {
8 labelResult.Text = "The originating page must contain" + "textFirstName, textLastName, textEmail controls";
9 }
浙公网安备 33010602011771号