如何给MASTERPAGE上的控件赋值。
在.net 2.0 中如果使用了masterPage,则不能像以前那样使用 FindControl,则需要使用如下方法
先找到ContentPlaceHolder,然后再找在这个ContentPlaceHolder中的你要找的控件
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
1
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
ContentPlaceHolder mpContentPlaceHolder;
Label mpTextBox;
mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("home");
if (mpContentPlaceHolder != null)
{
mpTextBox = (Label)mpContentPlaceHolder.FindControl("ctl00_member_name");
if (mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
else
{
Response.Write("Label fdfd");
}
}
else
{
Response.Write("ContentPlaceHolder fdfd");
}
還是有問題,依然不行。