在内容页中修改母版页中的内容
1,使用Title属性
<%@ Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page File" %>
2,使用
void Page_Load()
{
Page.Header.Title = String.Format("Header Content ({0})",DateTime.Now);
Style myStyle = new Style();
myStyle.BackColor = System.Drawing.Color.Red;
Page.Header.StyleSheet.CreateStyleRule(myStyle,null,"html");
}
{
Page.Header.Title = String.Format("Header Content ({0})",DateTime.Now);
Style myStyle = new Style();
myStyle.BackColor = System.Drawing.Color.Red;
Page.Header.StyleSheet.CreateStyleRule(myStyle,null,"html");
}
3,修改内容页的<meta>标签,为搜索引擎提供索引
void Page_Load()
{
HtmlMeta metaDesc = new HtmlMeta();
metaDesc.Name = "Description";
metaDesc.Content = "A sample of using HtmlMeta controls";
HtmlMeta metaKeywords = new HtmlMeta();
metaKeywords.Name = "Keywords";
metaKeywords.Content = "HtmlMeta,Page.Header,ASP.NET";
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(metaDesc);
head.Controls.Add(metaKeywords);
}
{
HtmlMeta metaDesc = new HtmlMeta();
metaDesc.Name = "Description";
metaDesc.Content = "A sample of using HtmlMeta controls";
HtmlMeta metaKeywords = new HtmlMeta();
metaKeywords.Name = "Keywords";
metaKeywords.Content = "HtmlMeta,Page.Header,ASP.NET";
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(metaDesc);
head.Controls.Add(metaKeywords);
}
4,对母版页使用FindControl()方法
//母版页中包含了名为ltlBodyTitle的Literal控件。
void Page_Load()
{
Literal ltlBodyTitle = (Literal)Master.FindControl("ltlBodyTitle");
ltlBodyTitle.Text = "The Body Title";
}
void Page_Load()
{
Literal ltlBodyTitle = (Literal)Master.FindControl("ltlBodyTitle");
ltlBodyTitle.Text = "The Body Title";
}