[英]ASP.NET: How can I pass standard information between Masters/Pages in the code-behind?
I need my child pages to be able to set the values of certain properties of the Master page before loading. 我需要我的子页面能够在加载之前设置母版页某些属性的值。
In other words, how my application builds the Master page for the client depends upon what properties are set by the child pages on the back-end. 换句话说,我的应用程序如何为客户端构建“母版”页面取决于后端子页面设置的属性。
For example: 例如:
public partial class mstrPage : System.Web.UI.MasterPage
{
public int Rows { get; set; }
public int Cols { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
/* Build a .NET two-dimensional-array of divs
that is <Rows> tall and <Cols> wide. */
}
}
In this example, the child page needs to set the values of <Rows>
and <Cols>
before Page_Load()
is invoked for the Master. 在此示例中,子页面需要在为母版调用
Page_Load()
之前设置<Rows>
和<Cols>
的值。
This is fairly simple to accomplish with inheritance in OOP, but ASP.NET web pages do not "inherit" their master pages in the code-behind. 使用OOP中的继承来完成此操作相当简单,但是ASP.NET网页不会在其背后的代码中“继承”其母版页。
In the given example, what would the code-behind look like for the ASP.NET child page that sets these properties? 在给定的示例中,设置这些属性的ASP.NET子页面的代码背后是什么样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.