Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Master sites with placeholder in head-tag

Master sites with placeholder in head-tag

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stefan Troschuetz
    wrote on last edited by
    #1

    Hi everybody, today i have started to take a look at ASP.NET 2.0. It has some nice features like the new master-sites (waited for something like this). But i've encountered the following problem. Is there a possibility to define a master-site that allows dynamic content inside the head-part? Background is, that my content sites should have different meta tags e.g. for date or keywords. The following code isn't working, but should illustrate what i want to do. Is there some possibility or do i have to look for other solutions? Thanks in advance!

    Master site:

    Content site:


    www.troschuetz.de

    M 1 Reply Last reply
    0
    • S Stefan Troschuetz

      Hi everybody, today i have started to take a look at ASP.NET 2.0. It has some nice features like the new master-sites (waited for something like this). But i've encountered the following problem. Is there a possibility to define a master-site that allows dynamic content inside the head-part? Background is, that my content sites should have different meta tags e.g. for date or keywords. The following code isn't working, but should illustrate what i want to do. Is there some possibility or do i have to look for other solutions? Thanks in advance!

      Master site:

      Content site:


      www.troschuetz.de

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, There are two options come to mind: + You can place the ContentPlaceHolder control between the open and close tags of the head element in the MasterPage:

      *************MasterPage.master******************
      <%@ Master Language="C#" %>

      <!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">
      <title>Untitled Page</title>
      <asp:contentplaceholder id="MetaTagContent" runat="server">
      </asp:contentplaceholder>
      </head>
      <body>
      <form id="form1" runat="server">
      <div>
      <asp:contentplaceholder id="MainContent" runat="server">
      </asp:contentplaceholder>
      </div>
      </form>
      </body>
      </html>

      *************ContentPage.aspx******************
      <%@ Page Language="C#" MasterPageFile="~/MyMasterPage.master" Title="Untitled Page" %>
      <asp:Content ID="Content1" ContentPlaceHolderID="MetaTagContent" Runat="Server">
      <meta name="date" content="2004-12-01T" />
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
      <h3>This is the main content</h3>
      </asp:Content>

      + You can programmatically add the the meta tag in the content page using the Page.Header[^] property.

      S 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, There are two options come to mind: + You can place the ContentPlaceHolder control between the open and close tags of the head element in the MasterPage:

        *************MasterPage.master******************
        <%@ Master Language="C#" %>

        <!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">
        <title>Untitled Page</title>
        <asp:contentplaceholder id="MetaTagContent" runat="server">
        </asp:contentplaceholder>
        </head>
        <body>
        <form id="form1" runat="server">
        <div>
        <asp:contentplaceholder id="MainContent" runat="server">
        </asp:contentplaceholder>
        </div>
        </form>
        </body>
        </html>

        *************ContentPage.aspx******************
        <%@ Page Language="C#" MasterPageFile="~/MyMasterPage.master" Title="Untitled Page" %>
        <asp:Content ID="Content1" ContentPlaceHolderID="MetaTagContent" Runat="Server">
        <meta name="date" content="2004-12-01T" />
        </asp:Content>
        <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
        <h3>This is the main content</h3>
        </asp:Content>

        + You can programmatically add the the meta tag in the content page using the Page.Header[^] property.

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Thanks for the reply. I tried the first option before posting here, but it doesn't work (get a compiler error that the tag prefix asp is unknown). Second option isn't as nice as the first one would be, but it does what i want.


        www.troschuetz.de

        M 1 Reply Last reply
        0
        • S Stefan Troschuetz

          Thanks for the reply. I tried the first option before posting here, but it doesn't work (get a compiler error that the tag prefix asp is unknown). Second option isn't as nice as the first one would be, but it does what i want.


          www.troschuetz.de

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Stefan Troschütz wrote:

          tried the first option before posting here, but it doesn't work (get a compiler error that the tag prefix asp is unknown).

          Don't worry about this error, it still works just fine, make sure that you don't have any other error when the build is OK when you compile your web site.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups