欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

动态修改页面的Title, Keywords and Description

程序员文章站 2022-07-05 22:54:47
protected void LoadPageProperty()     {         pageProper...
protected void LoadPageProperty()

    {

        pagePropertyModel = pageProperty.GetModel();

        //Description

        HtmlMeta desc = new HtmlMeta();

        desc.Name = "Description";

        desc.Content = pagePropertyModel.Desc_Content;

        Page.Header.Controls.Add(desc);

        //Keyword

        HtmlMeta keywords = new HtmlMeta();

        keywords.Name = "keywords";

        keywords.Content = pagePropertyModel.Keywords_Content;

        Page.Header.Controls.Add(keywords);

 

        //Page title

        Page.Title = pagePropertyModel.Title;

        ////Encode/Content type

        //HtmlMeta encode = new HtmlMeta();

        //encode.HttpEquiv = "Content-Type";

        //encode.Content = "text/html; charset=utf-8";

        //Page.Header.Controls.Add(encode);

        ////Language

        //HtmlMeta lang = new HtmlMeta();

        //lang.HttpEquiv = "Content-Language";

        //lang.Content = "zh-cn";

        //Page.Header.Controls.Add(lang);

        ////Description

        //HtmlMeta desc = new HtmlMeta();

        //desc.Name = "Description";

        //desc.Content = "Test the meta controls,FCC";

        //Page.Header.Controls.Add(desc);

        ////Keyword

        //HtmlMeta keywords = new HtmlMeta();

        //keywords.Name = "keywords";

        //keywords.Content = "title,meta,test,page,FCC检测";

        //Page.Header.Controls.Add(keywords);

        ////Link/CSS

        ////HtmlLink cssLink = new HtmlLink();

        ////cssLink.Href = "MasterPage.css";

        ////cssLink.Attributes.Add("rel", "stylesheet");

        ////cssLink.Attributes.Add("type", "text/css");

        ////Page.Header.Controls.Add(cssLink);

    }