Showing Page Title Via ASP

Using classic ASP, how can I display the page title from the HTML code
<title>Example Page</title>

Open in new window

It is probably something pretty simple, but searching leads me to databases, etc.  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Example Page</title>
</head>

<body>
<p>The Name of this page is: </p>
</body>

</html>

Open in new window

And on the parse code, it would show:
The Name of this page is: Example Page
LVL 29
coreybryantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
I presume your question is actually how to fetch the data from database, or get it into there?

<%
  ' here goes the code to query the database, whatever ...
  v_page_title = "Example Page"
  ' and you use that later on in the actual html
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title><%=v_page_title%></title>
</head>

<body>
<p>The Name of this page is: </p>
</body>

</html>

Open in new window

0
Amit KhilnaneyCommented:
In the coding view


The name of the page is  = Page.Title
The name of the page is = Page.Header.Title

Try with that

0
matija_Commented:
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Example Page</title>
</head>

<body>
<p>The Name of this page is: <script language="JavaScript">document.write (document.title)</script></p>
</body>

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

coreybryantAuthor Commented:
No, no database is involved.

I tried
Page.Title

Open in new window

and
Page.Header.Title

Open in new window

but that just displayed
Page.Title
and
Page.Header.Title
respectively.

The JavaScript code did work, but I was hoping to use ASP if it is available.

Thank you!
0
Amit KhilnaneyCommented:
Apologies, that was for asp.net
0
Wayne BarronAuthor, Web DeveloperCommented:
What exactly are you trying to show?
What is the title of the page, and where is the title coming from?
If not from a database, then where?
0
SeonyxCommented:
I think what you need to do is store the page title as a variable like this:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
Dim pagetitle
pagetitle = "Example Page"
%>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title><%response.write(pagetitle)%></title>
</head>

<body>
<p>The Name of this page is: <%response.write(pagetitle)%></p>
</body>

</html>
0
coreybryantAuthor Commented:
The page title is coming from the <title>
<title>Example Page</title>

Open in new window

I was hoping there was an easy way - almost similar to Seonyx way, but without having to add / store that in a separate field.

Corey
0
SeonyxCommented:
I think you'll find this is the easiest way to do it.

There are two other ways I can think of to do what you want.

1) Don't use ASP - do it in javascript or jquery when the page is loaded in the client's browser. That is a bit more fiddly and won't work in all situations (i.e. if javascript is disabled).

2) Write some code on the server that reads the contents page in and searches for the title and parses its contents. This would be slower to execute and and require much more development/testing time.
0
Wayne BarronAuthor, Web DeveloperCommented:
@Seonyx
Once you create the Variable, you do not have to use the response.write to write the variable's data out.

<%
Dim pagetitle
pagetitle = "Example Page"
%>

<%=pagetitle%>   <-- This is all that is needed, clean and neat.

Carrzkiss
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coreybryantAuthor Commented:
Can that
<%
Dim pagetitle
pagetitle = "Example Page"
%>

Open in new window

be anywhere or does it need to be in the <head>?

Thanks!
0
SeonyxCommented:
@carrzkiss yes you're absolutely right, though I used the full form for the sake of clarity.

@coreybryant  you can place that anywhere you like, even before the <html> tag and it will work just the same.
0
matija_Commented:
I think it's obvious by now, that it is IMPOSSIBLE to get the <title> with ASP without putting it in variable first. There is NO WAY to get it simply by reading/requesting <title> field because that command does not exist in classic ASP.

Experts here gave you solutions and you should either choose one of those, or give up.

Solution 1 (ASP variables):
<%
Dim strTitle
strTitle = "Example Page
%>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title><%=strTitle%></title>
</head>

<body>
<p>The Name of this page is: <%=strTitle%></p>
</body>

Open in new window


Solution 2 (JavaScript):

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Example Page</title>
</head>

<body>
<p>The Name of this page is: <script language="JavaScript">document.write (document.title)</script></p>
</body>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.