aspx 页面中的代码
<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>
在 aspx.cs(Codebehind) 中访问按钮 ID 的代码
Button watchList = (Button)loginView1.FindControl("btnWatchlist");
Button pm = (Button)loginView1.FindControl("btnPM");
Button report = (Button)loginView1.FindControl("btnReport");
Button edit = (Button)loginView1.FindControl("btnEdit");
watchList,pm,report,edit 得到空值。我的代码有错误吗?
提前致谢..