代码控制我有一些无法找到在超类
<%@ 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!
}
}
为什么没有方法无法找到控制?
这是一个重复http://stackoverflow.com/questions/839794/finding-a-control-in-a--page-from-a-page-base-class –