代碼控制我有一些無法找到在超類
<%@ 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 –