ASP Postback not finding field in previous page

xrust

New Member
I have this code below in Default2.aspx.cs which refers to a label from my previous page and I am experimenting with Postback from Page 50 of Microsoft Web Development Fundamentals. I'm getting the NullReference exception on the line tempLabel.Text and I was wondering what can cause this since the label definitely exists on the previous page.Many thanks!\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Page.PreviousPage != null) { Label tempLabel = (Label) PreviousPage.FindControl("LabelPostback"); LabelPostback2.Text = tempLabel.Text; } }}\[/code\]
 
Back
Top