怎么在后台修改前台html页面的key、title、description

 public void UpdateMeta(string title, string keyword, string desc)
    {

        for (int i = this.Header.Controls.Count - 1; i >= 0; i--)
        {
            if (this.Header.Controls[i].GetType() == typeof(HtmlMeta))
            {
                HtmlMeta hmt = (HtmlMeta)this.Header.Controls[i];
                if (hmt.Attributes["name"] != null)
                    this.Header.Controls.RemoveAt(i);
            }
        }
        this.Page.Title = title;

        HtmlMeta hm = new HtmlMeta();
        hm.Name = "keywords";
        hm.Content = keyword;
        Header.Controls.AddAt(1, hm);

        HtmlMeta hm1 = new HtmlMeta();
        hm1.Name = "description";
        hm1.Content = desc;
        Header.Controls.AddAt(2, hm1);
    }

 

posted @ 2016-12-12 10:50  一直乱跑的熊  阅读(1692)  评论(0编辑  收藏  举报