我有很多页
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="MyPage.aspx.cs" Inherits="MyPage " MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="commonForm" runat="server">
<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell ID="cellControl" />
</asp:TableRow>
</asp:Table>
</asp:Content>
public partial class MyPage : MySuperPage { }
和他们的超级班:
public abstract class MySuperPage : Page
{
public MySuperPage()
{
this.Load += new EventHandler(PageLoad);
}
// my own method
protected void PageLoad(object sender, EventArgs e)
{
var c = this.FindControl("cellControl"); // null!
}
// auto event handling
protected void Page_Load(object sender, EventArgs e)
{
var c = this.FindControl("cellControl"); // null!
}
}
为什么两种方法都找不到这个控件?