By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,930 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,930 IT Pros & Developers. It's quick & easy.

Page Title

P: n/a
How can I get the page title into an variable to handle in my asp.
Don
Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

P: n/a
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


"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #3

P: n/a
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)
%>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #4

P: n/a
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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


Jul 19 '05 #5

P: n/a
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>"
%>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #6

P: n/a
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" <sp******@assoft.com.au> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.