How to: unique HEAD (meta, scripts) on .aspx pages

Last post 05-08-2007 5:06 PM by jwadsworth. 5 replies.

Sort Posts:

  • How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 1:13 PM
    • Member
      22 point Member
    • SevenUX
    • Member since 04-30-2007, 4:07 PM
    • Posts 18

    Hi!

    How does a person add unique HEAD information such as meta-tage and scripts to the .aspx pages which use master.pages?

    Thanks in advance!!!

     

    <%@ Page Language="C#" MasterPageFile="Layout.master" Title="Hi" %> 


    <asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">

    </asp:Content>

    Timmy a 'User Experience' (UX) Consultant
    www.SevenUX.com
  • Re: How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 1:50 PM
    • Member
      111 point Member
    • roshanstevv
    • Member since 02-02-2007, 6:31 PM
    • Posts 55

    hi,

    I guess u are using a master page..So u need to add scripts and meta-tage etc in the master page.Not In the aspx.page..

    Go to the masterpage and add the neccessary things in the <head></head> part of this..

    U can add <script />, <meta />, <link /> etc in the head of the materpage..

    hope this will help,

    ------- 

    If u find this useful plz  mark this as answer..

     

    |__Roshan__|
  • Re: How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 2:07 PM
    • Contributor
      2,378 point Contributor
    • jwadsworth
    • Member since 03-13-2003, 12:16 PM
    • Salem, Oregon
    • Posts 542

    One way you could do it is to add code like the following to each page you want to have unique meta tags. You could put this in the page load.

    Dim metaTag As New HtmlMeta
    Dim HeadTag As HtmlHead = CType(Page.Header, HtmlHead)

    metaTag.Attributes.Add(

    "name", "description")
    metaTag.Attributes.Add(
    "content", "your description goes here")
    HeadTag.Controls.Add(metaTag)

    metaTag =

    New HtmlMeta
    metaTag.Attributes.Add(
    "name", "keywords")
    metaTag.Attributes.Add(
    "content", "your keyword go here")
    HeadTag.Controls.Add(metaTag)

     

  • Re: How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 3:00 PM
    • Member
      328 point Member
    • himawari
    • Member since 07-19-2006, 7:26 PM
    • Vancouver, BC
    • Posts 63

    As for the scripts, you can include javascript by using the following code in the Page_Load method of your content pages:

    ClientScript.RegisterClientScriptInclude("common", ResolveUrl("~/js/common.js"));
     
    Filed under: , ,
  • Re: How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 3:10 PM
    Answer
    • Member
      22 point Member
    • SevenUX
    • Member since 04-30-2007, 4:07 PM
    • Posts 18

    Thank you JWadsworth... you are always great help.

    Your solution worked and I also found another.

    In the MASTER page:

    <head runat="server">
    <asp:ContentPlaceHolder id="head" runat="server">

    </asp:ContentPlaceHolder>
    </head>

    In the .ASPX page

    <asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
    <title>14ers.com</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    </asp:Content>

    Timmy a 'User Experience' (UX) Consultant
    www.SevenUX.com
  • Re: How to: unique HEAD (meta, scripts) on .aspx pages

    05-08-2007, 5:06 PM
    • Contributor
      2,378 point Contributor
    • jwadsworth
    • Member since 03-13-2003, 12:16 PM
    • Salem, Oregon
    • Posts 542

    Ah, good idea. I haven't seen that method. Well this thread should be helpful to anyone trying to accomplish what you were trying to do.

    Filed under:
Page 1 of 1 (6 items)