C# Can';t从LoginView中的LoginTemplate访问控件
aspx页面中的代码C# Can';t从LoginView中的LoginTemplate访问控件,c#,asp.net,C#,Asp.net,aspx页面中的代码 <asp:LoginView ID="loginView1" runat="server" EnableViewState="false"> <LoggedInTemplate> <asp:Button ID="btnWatchlist" runat="server" Text="+ Watchlist" /> <asp:Button ID="b
<asp:LoginView ID="loginView1" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:Button ID="btnWatchlist" runat="server" Text="+ Watchlist" />
<asp:Button ID="btnPM" runat="server" Text="PM" />
<asp:Button ID="btnEdit" runat="server" Text="Edit" />
<asp:Button ID="btnReport" runat="server" Text="Report" />
</LoggedInTemplate>
</asp:LoginView>
监视列表、pm、报告、编辑获取空值。我的代码中有错误吗
提前感谢。可能是个愚蠢的问题,但您是否已登录到您的网站?测试时,我注意到控件只有在登录时才可见,因此在Page_Load中使用FindControl无法找到控件,除非我已登录
Button watchList = (Button)loginView1.FindControl("btnWatchlist");
Button pm = (Button)loginView1.FindControl("btnPM");
Button report = (Button)loginView1.FindControl("btnReport");
Button edit = (Button)loginView1.FindControl("btnEdit");