开发者

Reading Meta tags dynamically

Can someone please help me trying to figure out how to simply write the meta tags in an asp.n开发者_如何学Cet page. The meta tags have been inserted in the page and I just want to loop through them and write the keywords tag. I don't have a probably adding dynamically, just reading.


.

using System.Web.UI.HtmlControls;
// ...
List<HtmlMeta> metas = new List<HtmlMeta>();
foreach (Control c in this.Page.Header.Controls)
    if (c.GetType() == typeof(HtmlMeta))
    {
        HtmlMeta meta = (HtmlMeta)c;
        if (meta.Name == "Keywords")
            meta.Content = "content goes here";
        break;
    }

Edited to make useful to your situation...


Below link shows you how to manage your Meta tags & even SEO options.

http://www.programminghelp.com/web-development/asp-net/using-sitemap-and-masterpages-to-set-meta-tags-in-asp-net-and-c/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜