asp.net中動(dòng)態(tài)更改網(wǎng)站的標(biāo)題、描述、關(guān)鍵字、和樣式表
//asp.net中動(dòng)態(tài)更改網(wǎng)站的標(biāo)題、描述、關(guān)鍵字、和樣式表 |
if (!IsPostBack) |
{ |
//Page title網(wǎng)頁(yè)標(biāo)題 |
Page.Title = "我的網(wǎng)站標(biāo)題" ; |
//須將網(wǎng)頁(yè)head標(biāo)簽設(shè)成服務(wù)器控件模式,即<head runat="server">,否則無(wú)效 |
//Description網(wǎng)頁(yè)描述 |
HtmlMeta desc = new HtmlMeta(); |
desc.Name = "Description" ; |
desc.Content = "我的網(wǎng)站描述" ; |
Page.Header.Controls.Add(desc); |
|
//Keyword網(wǎng)頁(yè)關(guān)鍵字 |
HtmlMeta keywords = new HtmlMeta(); |
keywords.Name = "keywords" ; |
keywords.Content = "我的網(wǎng)站關(guān)鍵字" ; |
Page.Header.Controls.Add(keywords); |
|
//Link/CSS |
HtmlLink cssLink = new HtmlLink(); |
cssLink.Href = "css/search.css" ; |
cssLink.Attributes.Add( "rel" , "stylesheet" ); |
cssLink.Attributes.Add( "type" , "text/css" ); |
Page.Header.Controls.Add(cssLink); |
} |