我正在开发一个 .net 3.5 网站,标准网站项目。
我在站点 App_Code 文件夹 (MyPage) 中编写了一个自定义页面类。
我还有一个带有属性的母版页。
public partial class MyMaster : System.Web.UI.MasterPage
{
...
private string pageID = "";
public string PageID
{
get { return pageID; }
set { pageID = value; }
}
}
我正在尝试从 MyPage 中的属性中引用此属性。
public class MyPage : System.Web.UI.Page
{
...
public string PageID
{
set
{
((MyMaster)Master).PageID = value;
}
get
{
return ((MyMaster)Master).PageID;
}
}
}
我最终得到“找不到类型或命名空间名称‘MyMaster’。我已经通过使用 FindControl() 而不是 MyMaster 页面上的属性使其工作,但母版页中的 ID 可能会更改。