Re: how do I get a page's meta tag contents?

Discussion in 'ASP .Net' started by PJ6, Sep 20, 2005.

  1. PJ6

    PJ6 Guest

    Well that works but I think it's generally poor design to have any metadata
    collection require instantiation. I know there is some hocus-pocus going on
    in the background to build the temporary assemblies that support ASP.NET,
    but I don't think it could have been too much of a stretch to have included
    the meta tags as attributes in the created types that populate the ASP
    namespace.

    I was considering helping a client maintain their own metadata more easily
    by just letting them alter meta tags on the pages themselves. But having to
    instantiate each class to do something like collect metadata for all pages
    just isn't going to fly. I'll have to use real attributes on the underlying
    vb classes, and alteration of metadata will require editing the code itself
    and a recompile, or perhaps I'll store it in SQL Server using a loose data
    model if I don't consider that overkill for this particular project.

    Paul

    "Joe" <> wrote in message
    news:...
    > this is how i did it
    >
    > first make class that inherits from page
    > ---------------------------------------------
    > using System.Text;
    > using System.Web.UI;
    > using System.IO;
    >
    > namespace WebPageBase
    > {
    > public class PageBase : System.Web.UI.Page
    > {
    >
    > protected System.Web.UI.HtmlControls.HtmlGenericControl alsideKeywords;
    >
    >
    > public string alsideKey
    > {
    > get
    > {
    > return alsideKeywords.Attributes["content"].ToString();
    > }
    > set
    > {
    > alsideKeywords.Attributes["content"] = value;
    > }
    > }
    >
    >
    > then make your meta tags "runat=server"
    > -------------------------------------------------
    >
    >
    > <meta name="keywords" id="alsideKeywords" content="Windows Siding"
    > runat="server"/>
    >
    > make sure your page inherits from the new class and access like this
    > -------------------------------------------------------------------------------
    >
    > // dr is a datareader
    > //sets keywords
    > if(dr["keywords"] != DBNull.Value)
    > ((WebPageBase.PageBase)Page).alsideKey = dr["keywords"].ToString();
    > else ((WebPageBase.PageBase)Page).alsideKey = "Alside - Windows and
    > Siding";
    >
    > HTH.......
    >
    > Joe
    >
    >
    >
    > "PJ6" wrote:
    >
    >> Can't find anywhere in the docs that mentions a way to programmatically
    >> get
    >> a page's meta tag collection. Reflection finds nothing in attributes.
    >> Can't
    >> find anything in a page instance, either. Are they not accessible?
    >>
    >> Paul
    >>
    >>
    >>
     
    PJ6, Sep 20, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  2. Nym Pseudo

    META NAME and META HTTP-EQUIV

    Nym Pseudo, Sep 26, 2003, in forum: HTML
    Replies:
    1
    Views:
    573
    =?iso-8859-1?Q?brucie?=
    Sep 26, 2003
  3. dongdong
    Replies:
    7
    Views:
    1,228
    John J. Lee
    Mar 23, 2006
  4. Duane Johnson

    Meta methods to govern meta data?

    Duane Johnson, Oct 25, 2005, in forum: Ruby
    Replies:
    6
    Views:
    250
    Adam Sanderson
    Oct 28, 2005
  5. Erik Veenstra

    Meta-Meta-Programming

    Erik Veenstra, Feb 7, 2006, in forum: Ruby
    Replies:
    29
    Views:
    414
    Erik Veenstra
    Feb 8, 2006
Loading...

Share This Page