【发布时间】:2011-02-10 10:42:28
【问题描述】:
我有以下环境:
- 带有 contentPlacholder 的母版页
- 使用此母版页并实现基类 (
fooPage) 的多个页面 -
fooPage有一定的属性(fooProperty)
现在我想做类似的事情
public partial class FooMaster : System.Web.UI.MasterPage
{
// this is originally from the designer-file
protected global::System.Web.UI.WebControls.ContentPlaceHolder ContentPlaceHolder;
protected override void OnPreRender(System.EventArgs e)
{
var fooPageInstance = this.ContentPlaceHolder as fooPage;
var fooPropertyInstance = fooPageInstance.fooProperty;
// TODO do something with the property
}
}
显然这是行不通的 - 但我怎样才能做到这一点?
我知道另一种选择:从 contentPage 中的 masterPage 调用一个方法,并使用 fooProperty 作为参数 - 但在这种情况下我宁愿有一个拉系统...
【问题讨论】:
-
@abatishchev:感谢您的编辑,但从
System.Web.UI.MasterPage中删除命名空间有点不必要...为了清楚起见,我包含命名空间!顺便提一句。为什么不给page一个大写的P?? :)
标签: c# .net asp.net webforms master-pages