[导入]使用Master页

在内容页中有两种方法访问Master页中的信息。

1. 使用Master.FindControl()方法查找Master页中的控件。

2. 在Master页中定义公用属性,并通过Master.Property=xxx的方式来访问。

以编程方式指定页面的Master页。

Page.MasterPageFile="xxx" 'OK

这个方法必须在Page的PreInit事件中调用,并且在Page中必须包含正确的Content控件,否则会抛出一个异常。

使用Master时的页面事件顺序如下

Page PreInit

MasterPage Init

Page Init

Page InitComplete

Page PreLoad

Page Load

MasterPage Load

Page LoadComplete

Page PreRender

Masterpage Prerender

Page PreRenderComplete


文章来源:http://blog.163.com/jhdzkfb22@126/blog/static/45843475200811282334360
原文地址:https://www.cnblogs.com/shangfc/p/1067669.html