Reading Page Title?

  • Thread starter Chad A. Beckner
  • Start date
C

Chad A. Beckner

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
 
B

bruce barker

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)
 
C

Chad A. Beckner

Ok, any idea of how to access this?

Chad

bruce barker said:
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)
 
J

John Saunders

Chad A. Beckner said:
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).
 
C

Chad A. Beckner

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
 
J

John Saunders

Chad A. Beckner said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top