Page.MetaKeywords in ASP.NET

Ashok
Ashok used Ask the Experts™
on
Page.MetaKeywords

and

Page.MetaDescription

in ASP.NET website, do you store above values in defaults.aspx only?

or

in all pages?

inside "protected void Page_Load(object sender, EventArgs e) { "
event.

Thanks,
Ashok
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You need to define/implement these properties in all pages individually.
Reason behind is that every page will have different content hence different keyword & descriptions will be used.

You can set these in the page_load.

In case you want to set these properties only to one value regardless of the page, you can create a general method in a new class file and call that on page_load of every page.


Create a class and put below method in it.

public void fillMetaTags(string textInfo, string title, Page objPage)
    {
        try
        {
            objPage.Header.Title = "YourSite.com : " + title;

            HtmlMeta keywords = new HtmlMeta();
            keywords.Name = "keywords";
            keywords.Content = "some keywords";

            HtmlMeta description = new HtmlMeta();
            description.Name = "Description";
            description.Content = textInfo;

            objPage.Header.Controls.Add(keywords);
            objPage.Header.Controls.Add(description);

        }
        catch (Exception ex)
        {
            //
        }
    }


Now in your aspx code behind page load :
fillMetaTags("some text", "title", this.Page);

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial