Reading Page Title?

Discussion in 'ASP .Net' started by Chad A. Beckner, Jun 3, 2004.

  1. Does anyone know how to read the page title the executing page, using
    ASP.NET? I thought that this could be accessed using the Controls
    collection, but I can't seem to figure it out.

    Thanks!

    Chad
     
    Chad A. Beckner, Jun 3, 2004
    #1
    1. Advertising

  2. Chad A. Beckner

    bruce barker Guest

    unless you put runat=server on the title tag in the html, it will be inside
    one the literals in the page controls collection.

    -- bruce (sqlwork.com)


    "Chad A. Beckner" <> wrote in message
    news:#...
    > Does anyone know how to read the page title the executing page, using
    > ASP.NET? I thought that this could be accessed using the Controls
    > collection, but I can't seem to figure it out.
    >
    > Thanks!
    >
    > Chad
    >
    >
     
    bruce barker, Jun 3, 2004
    #2
    1. Advertising

  3. Ok, any idea of how to access this?

    Chad

    "bruce barker" <> wrote in message
    news:...
    > unless you put runat=server on the title tag in the html, it will be

    inside
    > one the literals in the page controls collection.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Chad A. Beckner" <> wrote in message
    > news:#...
    > > Does anyone know how to read the page title the executing page, using
    > > ASP.NET? I thought that this could be accessed using the Controls
    > > collection, but I can't seem to figure it out.
    > >
    > > Thanks!
    > >
    > > Chad
    > >
    > >

    >
    >
     
    Chad A. Beckner, Jun 3, 2004
    #3
  4. "Chad A. Beckner" <> wrote in message
    news:%...
    > Does anyone know how to read the page title the executing page, using
    > ASP.NET? I thought that this could be accessed using the Controls
    > collection, but I can't seem to figure it out.


    You have to use:

    <head>
    <title runat="server" id="myTitle">Page title</title>
    </head>

    Then in your code you can access myTitle.InnerText to get the text.

    If a given page doesn't have a <title> with runat="server", then there is no
    way to retrieve the page title (if there is one).
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 3, 2004
    #4
  5. But that won't work on static .htm files. I also need to access the meta
    tags (since my site template .ascx file is generating the <head> element).
    Ideas?

    Chad

    "John Saunders" <> wrote in message
    news:...
    > "Chad A. Beckner" <> wrote in message
    > news:%...
    > > Does anyone know how to read the page title the executing page, using
    > > ASP.NET? I thought that this could be accessed using the Controls
    > > collection, but I can't seem to figure it out.

    >
    > You have to use:
    >
    > <head>
    > <title runat="server" id="myTitle">Page title</title>
    > </head>
    >
    > Then in your code you can access myTitle.InnerText to get the text.
    >
    > If a given page doesn't have a <title> with runat="server", then there is

    no
    > way to retrieve the page title (if there is one).
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
     
    Chad A. Beckner, Jun 3, 2004
    #5
  6. "Chad A. Beckner" <> wrote in message
    news:...
    > But that won't work on static .htm files. I also need to access the meta
    > tags (since my site template .ascx file is generating the <head> element).
    > Ideas?


    You can't do it.
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 3, 2004
    #6
  7. Check out this article this might help you,
    http://authors.aspalliance.com/kenc/faq5.aspx

    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Chad A. Beckner" <> wrote in message
    news:#...
    > Does anyone know how to read the page title the executing page, using
    > ASP.NET? I thought that this could be accessed using the Controls
    > collection, but I can't seem to figure it out.
    >
    > Thanks!
    >
    > Chad
    >
    >
     
    Saravana [MVP], Jun 4, 2004
    #7
    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. Andreas Klemt
    Replies:
    1
    Views:
    482
    Steve C. Orr, MCSD
    Aug 10, 2003
  2. Replies:
    0
    Views:
    560
  3. Replies:
    1
    Views:
    577
    David
    Apr 24, 2007
  4. soonic
    Replies:
    11
    Views:
    1,825
    soonic
    Jul 27, 2011
  5. Russell
    Replies:
    2
    Views:
    316
    Russell
    Sep 13, 2004
Loading...

Share This Page