here is the way to do so,
Code for page2.aspx.cs
declare Globally the number of objects you want to access from previous page
ie
private TextBox txt_1, txt_2, txt_3;
txt_1 = this.FindControl("TextBox1", PreviousPage.Controls) as TextBox; txt_2 = this.FindControl("TextBox2", PreviousPage.Controls) as TextBox; txt_3 = this.FindControl("TextBox3", PreviousPage.Controls) as TextBox; Label1.Text = txt_1.Text; Label2.Text = txt_2.Text; Label3.Text = txt_3.Text; private Control FindControl(string controlID, ControlCollection controls) { foreach (Control c in controls) { if (c.ID == controlID) return c; if (c.HasControls()) { Control cTmp = this.FindControl(controlID, c.Controls); if (cTmp != null) return cTmp; } } return null; }
No comments:
Post a Comment