Page Title

E

Evertjan.

Don Grover wrote on 31 jan 2004 in microsoft.public.inetserver.asp.general:
How can I get the page title into an variable to handle in my asp.

The question is not very clear,
as we do not know what you mean with "my ASP",
but let's assume you mean a serverside variable:

<% pageTitle = "This is page One" %>
<title><%=pageTitle%></title>

If, however, you mean a clientside variable,
please ask in a clientside NG.
 
D

Don Grover

Thanks for answering Evertjan
I did not want to rabbit on about it But !,.

I am using a whoson.asp page that at the moment displays the script name ie
mypag.asp in the display.
Instead of this I want to use the page title their on.
This is coming from an include file tagged onto every asp page on my site.

What I want to do on server side is grab the page title and stick it in a
vbscript variable to I can pick it up in the include and replace the page
name with the page title.
I dont want to have to do this on 250 pages & development site pages
<% pageTitle = "This is page One" %>
<title><%=pageTitle%></title>

There must be a way to grab the page title server side. ?

Don
 
E

Evertjan.

Don Grover wrote on 31 jan 2004 in
microsoft.public.inetserver.asp.general:
What I want to do on server side is grab the page title and stick it
in a vbscript variable to I can pick it up in the include and replace
the page name with the page title.
I dont want to have to do this on 250 pages & development site pages
<% pageTitle = "This is page One" %>
<title><%=pageTitle%></title>

There must be a way to grab the page title server side. ?

[please do not toppost on usenet]

Sure there is, but setting an include on all your 250 pages can easily
be done with an advanced editor like Editpad in one go.

Otherwise, do you want to insert the title serverside every time a page
is called?

==============

So you want to grab the page title and insert it into the page name?
In my book the page name is the same as the page title. ;-)

Please define.

===============

Changing the page name/title can be done with serverside Regex:

Jscriptlike serverside Pseudocode:

<%
t = getPageAsString("mypage.asp")
t = t.replace(/<title>(.*)?<\/title>/im,"my new title")
ReplacePageWithString("mypage.asp",t)
%>
 
D

Don Grover

Evertjan. said:
Don Grover wrote on 31 jan 2004 in
microsoft.public.inetserver.asp.general:
What I want to do on server side is grab the page title and stick it
in a vbscript variable to I can pick it up in the include and replace
the page name with the page title.
I dont want to have to do this on 250 pages & development site pages
<% pageTitle = "This is page One" %>
<title><%=pageTitle%></title>

There must be a way to grab the page title server side. ?

[please do not toppost on usenet]

Sure there is, but setting an include on all your 250 pages can easily
be done with an advanced editor like Editpad in one go.

Otherwise, do you want to insert the title serverside every time a page
is called?

==============

So you want to grab the page title and insert it into the page name?
In my book the page name is the same as the page title. ;-)

Please define.

===============

Changing the page name/title can be done with serverside Regex:

Jscriptlike serverside Pseudocode:

<%
t = getPageAsString("mypage.asp")
t = t.replace(/<title>(.*)?<\/title>/im,"my new title")
ReplacePageWithString("mypage.asp",t)
%>
I have editpad, but the Title is hard coded ie. like <title>PURCHASING :
ADD</title>
using editpad i know i can fly through all pages and add a line feed and
new line containing <% myVar = something.title %> after the </title>
but what code can i add to the page to put the title in a vbscript variable
'myVar'
it will then renew it every time page loads, and I can pick up var in
existing footer code.
Thats as clear as Ican make it ?.
Don
 
E

Evertjan.

Don Grover wrote on 31 jan 2004 in
microsoft.public.inetserver.asp.general:
I have editpad, but the Title is hard coded ie. like
<title>PURCHASING : ADD</title>

Editpad can replace across multiple files with Regex,
so I think you can replace the regex string:

<title>.*?<\/title>

with

<% response.write "<title>" & myTitle & "</title>" %>

or even better with

<!--#include virtual ="/myTitleInserter.inc.asp"-->

in this latest case you can later change the whole title setup
by filling the file "/myTitleInserter.inc.asp" with:


<%
rsv = request.servervariable("SCRIPT_NAME")
if rsv = "/q/bonny.asp" then
myTitle = "Marvellous Title"
else
myTitle = "Normal Title"
end if
response.write "<title>" & myTitle & "</title>"
%>
 
T

Tim Williams

You could always use client-side javascript to write out the parts of
the page which contain the title (failing gracefully on non js-enabled
browsers of course...)

Tim



Don Grover said:
Evertjan. said:
Don Grover wrote on 31 jan 2004 in
microsoft.public.inetserver.asp.general:
What I want to do on server side is grab the page title and stick it
in a vbscript variable to I can pick it up in the include and replace
the page name with the page title.
I dont want to have to do this on 250 pages & development site pages
<% pageTitle = "This is page One" %>
<title><%=pageTitle%></title>

There must be a way to grab the page title server side. ?

[please do not toppost on usenet]

Sure there is, but setting an include on all your 250 pages can easily
be done with an advanced editor like Editpad in one go.

Otherwise, do you want to insert the title serverside every time a page
is called?

==============

So you want to grab the page title and insert it into the page name?
In my book the page name is the same as the page title. ;-)

Please define.

===============

Changing the page name/title can be done with serverside Regex:

Jscriptlike serverside Pseudocode:

<%
t = getPageAsString("mypage.asp")
t = t.replace(/<title>(.*)?<\/title>/im,"my new title")
ReplacePageWithString("mypage.asp",t)
%>
I have editpad, but the Title is hard coded ie. like
 

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
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top