I am trying to assign text to a label by finding a control (textbox) on previous page. The control is accurately found, but the text cannot be assigned. Intellisense does not show "Text" property. How to get the text?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Control ctContent = this.PreviousPage.Master.FindControl("MainContent");
Control ct = (TextBox) ctContent.FindControl("TextBox1");
//TextBox t = (TextBox) Page.PreviousPage.Master.FindControl("TextBox1");
Label1.Text = String.Format("This is what you wrote there: {0}",ct.??????);
}
}
Instead
Control ct = (TextBox) ctContent.FindControl("TextBox1");
just write
TextBox ct = (TextBox) ctContent.FindControl("TextBox1");