【发布时间】:2014-01-26 16:59:04
【问题描述】:
我在角色组下的登录视图下的母版页中有一个用户控件。这是控件。它不在内容占位符中。但是,如果我尝试访问它,我得到空结果。我怎样才能访问它从我后面的页面代码。我在从母版页获取它时遇到问题。
<asp:RoleGroup Roles="Students">
<ContentTemplate>
<uc1:studentsPanel runat="server" ID="studentcontrol" />
</ContentTemplate>
</asp:RoleGroup>
这是我的代码
LoginView control = Page.Master.FindControl("studentcontrol") as LoginView;
if (control != null)
{
Label1.Text = "found";
}
【问题讨论】:
-
你在什么情况下试图访问这个?
-
我不认为
Page.Master.FindControl是要走的路。我可能是错的,但你试过Page.FindControl吗? -
我在页面加载中使用它。find 控件也返回 null。