2

我知道许多内容页面将使用 txtCustomerName 创建文本框控件。如果发现这一点,我需要更新会话中的值。在这种特殊情况下,我无法将这些控件移动到母版页。

如何从母版页访问页面控件。在页面生命周期的哪个事件中,我们应该尝试这样做?

4

1 回答 1

4

你可以在任何你想要的事件中找到,就像在这个例子中我向你展示的按钮点击事件

protected void Button1_Click(object sender, EventArgs e)
{
   TextBox TextBox1 = ContentPlaceHolder1.FindControl("TextBox1") as TextBox;
   if (TextBox1 != null)
   {
       Label1.Text = TextBox1.Text;
   }
}
于 2012-09-20T11:20:02.690 回答