访问用户控件中的TextBox
我制作了一个在线编辑器控件(ascx),需要在aspx页面上访问编辑器内容时出了问题,可以使用FindControl找到控件,但无法使用TextBox的属性如TextBox.Text,请问应该如何写?
public partial class AddNews : System.Web.UI.Page
{
TextBox newTextBox = null;
protected void Page_Load(object sender, EventArgs e)
{
Control MyControl = this.NewsEditor.FindControl("MyTextBox");
if (MyControl != null)
{
newTextBox = (TextBox)MyControl;
Response.Write("it's not null" + MyControl.Parent.ID + " " + newTextBox.Text);
}
else
{
Response.Write("it's null");
}
}
}
现在newTextBox.Text为空,而用户控件里的TextBox.Text不为空。