在母版頁後面的代碼,我創建meta標籤:從母版頁覆蓋Meta標籤與內容頁面的meta標籤
HtmlMeta _metaDescription = new HtmlMeta();
_metaDescription.Name = "description";
_metaDescription.Content = "this is the description";
_metaDescription.ID = "metaD";
this.Page.Header.Controls.Add(_metaDescription);
HtmlMeta _metaKeywordsMaster = new HtmlMeta();
_metaKeywordsMaster.Name = "keywords";
_metaKeywordsMaster.Content = "here are the keywords" ;
_metaDescription.ID = "metaK";
this.Page.Header.Controls.Add(_metaKeywordsMaster);
HtmlMeta _metaTitleMaster = new HtmlMeta();
_metaTitleMaster.Name = "title";
_metaTitleMaster.Content = "TitlePage";
_metaDescription.ID = "metaT";
this.Page.Header.Controls.Add(_metaTitleMaster);
如果我輸入一個特定的contentpage我想通過去除覆蓋這些元每日新聞他們和創建新的中繼標記
HtmlMeta meta = (HtmlMeta)this.Header.FindControl("ctl00metaT");
this.Header.Controls.Remove(meta);
HtmlMeta _metaDescription = new HtmlMeta();
_metaDescription.Name = "description";
_metaDescription.Content = "NewDescription";
base.Master.Page.Header.Controls.Add(_metaDescription);
//this.Page.Controls.Add(_metaDescription);
HtmlMeta _metaKeywords = new HtmlMeta();
_metaKeywords.Name = "keywords";
_metaKeywords.Content = "NewKeywords";
base.Master.Page.Controls.Add(_metaKeywords);
//this.Page.Controls.Add(_metaKeywords);
HtmlMeta _metaTitle = new HtmlMeta();
_metaTitle.Name = "title";
_metaTitle.Content = "NewTitle";
base.Master.Page.Controls.Add(_metaTitle);
但它並沒有刪除舊的標籤,我得到雙重標籤,而是我做錯了什麼?
此頁面不再存在。我會喜歡看到答案是什麼。 3年後我遇到了這個問題! – jlg 2016-08-11 17:13:25