MasterPage学习

来源:互联网 发布:酒神淘宝店 编辑:程序博客网 时间:2024/05/22 11:37

一、修改 Master Page 的标题部分

  HtmlHead head=this.Master.Page.Header;   //......   HtmlMeta meta=new HtmlMeta();    meta.Name="Keywords";    meta.Content="xxx网是全宇宙最牛X的网站";    head.Controls.Add(meta);

二、 查找MasterPage中的控件(内容页用母版页中的东东)
(1).FindControl方法:this.Master.Page.Form.FindControl("控件名")
(2).在MasterPage定义属性:
public XXX控件类型 MyXXXControl
{
get{return this.XXXControl;}
}
使用时:MasterPage的类名 master = (MasterPage的类名)this.Master;
(3).MasterType指令
在内容页头加入:<%@ MasterType VirtualPath="~/Site1.Master" %>
代码中可直接使用了:this.Master.控件名.BackColor = System.Drawing.Color.Green;


原创粉丝点击