根据类分析,Master的子控件只能是ContentRegion,否则也会被忽略掉的。 2.2.2 在OnInit中控制该控件初始化需要两步 2.2.2.1 BuildMasterPage加载皮肤 根据context提取出skin,加载skin的TemplagteFile。把该控件中所有Visible的子控件加到当前的控件容器Controls里,同时把TemplagteFile中的所有子控件清除,最后增加没有子控件的TemplateFile: this.Controls.AddAt(0, this.template)。注意,这些控件只是当前页面控件,嵌在层中或子控件中等并不会加进来。 2.2.2.2 BuildContents加载布局 foreach (ContentRegion content in this.contents) ,根据ID在MasterPage中寻找同名的Control region,先把region里边的控件清除,把content中的Controls移除到region中来。
2.3 DottextMasterPage : System.Web.UI.Page
InitializeBlogPage(),根据缓存中的控件名集合,加载相应skin目录下的控件。这些控件名,是UrlReWriteHandlerFactory.GetHandler()针对web.config对那些HandlerType.Direct的Handler类型进行设置的。
<HttpHandler pattern="/rss/.aspx$" type="...RssHandler, Dottext.Common" handlerType="Direct" />
<HttpHandler pattern="/CommentsRSS/.aspx$" type=".., .." handlerType="Direct" />
1.根据context中的键值对,设置标题;获取控件URL重写配置中的控件列表,加入CenterBodyControl中。Control c = LoadControl(ControlLocation);
c.ID = Regex.Replace(control,"(.ascx)$",string.Empty,RegexOptions.IgnoreCase)+"1";
CenterBodyControl.Controls.Add(c);