Meta Tags

Last post 05-16-2008 9:45 PM by mbanghart. 3 replies.

Sort Posts:

  • Meta Tags

    05-07-2008, 10:26 AM
    • Loading...
    • mbanghart
    • Joined on 05-07-2008, 10:23 AM
    • Posts 7

    Hi, I am new to ASP.net and have a question. I am trying to add meta tags to my page.  I use a master page with several content pages.  Could I just add he following to the master page?  Would it work?  I don't need different meta tags on each page. 

     Thanks!

     <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MainContent.master.cs" Inherits="MainContent" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <link href="Stylesheets/OkaloosaText.css" rel="stylesheet" type="text/css" />
        <title>Okaloosa Rugby Football Club</title>
        <META name="Keywords" content="okaloosa rfc,okaloosa rugby football club,rugby,ruggers,sports,emerald coast,destin,american rugby league,fort walton beach, shalimar, eglin air force base, eglin afb, hurlburt field, cheers pub,kj's,niceville">
        <META name="Abstract" content="Okaloosa Rugby Football Club!">
        <META name="Description" content="Okaloosa RFC is a premier Rugby team and club in the Emerald Coast! New and old players welcome!">
        <META name="Title" content="Okaloosa RFC is a premier Rugby team and club in the Emerald Coast! New and old players welcome!">
        <META name="Revisit-After" content="30">  
    </head>

  • Re: Meta Tags

    05-07-2008, 11:04 AM
    Answer
    • Loading...
    • kamii47
    • Joined on 05-26-2005, 4:04 PM
    • Karachi, Pakistan
    • Posts 1,405
    Kamran Shahid(MCSD.NET)
    Sr. Software Engineer
    Netprosys Inc.
    www.netprosys.com
    Microsoft Gold Certified Partner


    Please remember to click "Mark as Answer" on the post that helps you
  • Re: Meta Tags

    05-08-2008, 10:36 PM
    Answer

    Hi,

    Are you using VS 2005 or VS 2008.

    If you are using VS2008, you can notice there is a contentplaceholder in the head section of the master page, and there is a content control maps to the head contentplaceholder in the content page, then you can add add additional scripts and metadata in the content page in stead of <HEAD>.

    If you are using VS 2005, you can add a contentplaceholder control in the head in the master manually, and add a content control in the content page maps to the contentplaceholder manually.

    for example:

    1. the master page:

    <%@ Master Language="C#" %>
    ...
    <head runat="server">
        ...
        <asp:ContentPlaceHolder runat="server" id="headerPlaceHolder" />
    </head>
    ...

    2. the content page:

    <%@ Page Language="C#" MasterPageFile="~/Master1.master" Title="Foo" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="headerPlaceHolder"  runat="Server">
                
      <meta name="keywords" content="declassified information" />
      <style type="text/css" media="all">
          @import "wildstyle.css";
      </style>
      <script type="text/javascript" src="foo.js"></script>
    </asp:Content>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderID1"  runat="Server" />

    But you also can add the meta tags for the content page in the page codebehind.

            HtmlMeta meta = new HtmlMeta();
            
            meta.Content = DateTime.Now.ToString("yyyy-MM-dd");
            meta.Scheme = "YYYY-MM-DD";
            meta.Attributes.Add("charset", "utf-8");

            meta.Name = "date";
            this.Header.Controls.Add(meta);

    Hope it helps.

     

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Yours sincerely,
    Amanda Wang
    Microsoft Online Community Support
  • Re: Meta Tags

    05-16-2008, 9:45 PM
    • Loading...
    • mbanghart
    • Joined on 05-07-2008, 10:23 AM
    • Posts 7

    Thank You!

Page 1 of 1 (4 items)