<title> tag

G

Guest

Is it possible to use a field from the results from a DBRW to dynamically
change the <title> tag in an asp please. Instead of every results page from
the DBRW having the same <title> I want to pick up one field from the DBRW
and replace it. I suspect the answer already, however its worth asking...
many thanks
 
M

Murray

Sure.

<title><% your field value here %> any other constant content you want
here</title>
 
G

Guest

Thanks to Kathleen and Murray, you two certainly are "assets" to the group.
thanks mick
 
C

Clark

That is so cool. I gotta learn that stuff.

A question: Hope I am usnig the right terms here -- Kathleen defined a
variable first and then called it when she wanted it, Murray just put
the code directly in.

Is there and advantage to Kathleen's method other than the obvious one
that it would be easier to use her snippet multiple times on a page?
 
M

Murray

Her code was cuter than mine.

I'd say hers was more rigorous than mine too, for whatever that's worth....
8)
 
G

Guest

Hi Kathleen, sorry Im still struggling with this one. I have created a white
label test page at http://www.surproperties.com/asp/test2.asp?id=1532 , hope
this is helpful.
What Im trying to achieve, is when selecting a specific property using the
ID field (Im ok with that one, in this case 1532) is for the ASP to pick up
the "Location" field from the DBRW results and display the "location" field
within the page title, so the page title reads "Your Property in "Location""
rather than what is typed between the <title> tags, so the <title>tag changes
dynamically with each value from the "location" field. So property in this
case 1532 is in Playa de Las americas, and the page title would read property
"Your Property in Playa de las Americas" and 1531 is in Fanabe, so the title
would then read "Your Property in Fanabe".
Thanks again for your help and interest.
 
K

Kevin Spencer

Let me expound a bit on Kathleen's advice. Sometimes a little understanding
of the technology is in order. Forgive me if I tell you anything you already
know, as I don't know what you already know.

An ASP script is embedded into an ASP page by means of the <% and %> tags.
Anything between these tags is ASP scripting code.

ASP scripting code is interspersed with HTML in an ASP page. The HTML is
simply sent as is, and the ASP script performs operations on the server
prior to the sending of the page, which can affect or add to the HTML in the
page that is received by the browser. The scripting is not sent to the
browser, only the HTML and any output from the script.

HTTP is a Request/Response protocol. When you type a URL into a browser's
address window, or click a hyperlink, the browser sends a Request message to
the web server for the resource located at the URL. The web server responds
by sending a Response message, which includes an HTML document (usually).

In ASP, you have 2 intrinsic objects which are used to get access to this
system: Request and Response (surprise, surprise!). The Request object is
used to read data in the Request message, which is exposed as a Collection
of name/value pairs in the object. The Request can include either URL query
string variables (e.g. http..../somepage.asp?name=value) and form field
values, when a form is submitted (form field name, and form field value), or
both. This data is obtained using the syntax:

value = Request(name)

A variable is a storage container for data. You put data into the container
by assigning it using the '=' character:

variableName = Request(name) (puts the value from Request(name) into the
variable "variableName")

Now, in order to continue, I need to explain a little about the Response
object. An HTTP Response is a text message that includes an HTML document.
It is *written* to a stream that is sent to the browser. So, the chief
method of the Response object is Response.Write, which writes to the output
stream. The location in the page determines where that value will be
inserted. As HTML is written directly, and interspersed with ASP code, the
ASP code can write stuff among and between the HTML being sent. A typical
Response.Write statement might look like the following (shown inside ASP
tags):

<%Response.Write("Hello World")%>

However, there is also a *shorthand* notation for Response.Write, which is
the '=' character. The following example writes the same as the previous:

<%="Hello World"%>

Now, if that piece of script were inside the <title> tag of an ASP page, as
in:

<title><%="Hello World"%></title>

The HTML document on the client would have:

<title>Hello World</title>

So, putting it all together, you have ASP code written by the DBRW, which
does all this for you. If you want to put in a value from a form field that
posted to your results page, you would put:

<%=Request("formFieldName")%>

If it is a variable, you would put:

<%=variableName%>

Note the difference in the quoting. In the first example, you are referring
to a member of a Collection by its name. In the second, you are referring
directly to the contents of a variable with the name "variableName". In
essence, you treate the variableName as if it were the data that is
contained in the variable.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
S

Stefan B Rusynko

Good explanation but doesn't solve the OP's problem (-;

OP wants to display Page Title from a DB
(based on a parameter passed from a URL)
Page Titles are meta data in HEAD section of page
OP is using DBRW (very limited capability)
DBRW will only run inside of the BODY section of a page
- so it is not possible to do the DB query before the page title is processed w/ the DBRW
(all that can be displayed is the query parameter string value as per
http://spiderwebwoman.com/resources/dbrwtipsandtricks.asp#dynamic)

Using classic ASP and a hand coded DB connection query it would work as you explained
(since the DB lookup of the query string could occur above the HEAD tag)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Let me expound a bit on Kathleen's advice. Sometimes a little understanding
| of the technology is in order. Forgive me if I tell you anything you already
| know, as I don't know what you already know.
|
| An ASP script is embedded into an ASP page by means of the <% and %> tags.
| Anything between these tags is ASP scripting code.
|
| ASP scripting code is interspersed with HTML in an ASP page. The HTML is
| simply sent as is, and the ASP script performs operations on the server
| prior to the sending of the page, which can affect or add to the HTML in the
| page that is received by the browser. The scripting is not sent to the
| browser, only the HTML and any output from the script.
|
| HTTP is a Request/Response protocol. When you type a URL into a browser's
| address window, or click a hyperlink, the browser sends a Request message to
| the web server for the resource located at the URL. The web server responds
| by sending a Response message, which includes an HTML document (usually).
|
| In ASP, you have 2 intrinsic objects which are used to get access to this
| system: Request and Response (surprise, surprise!). The Request object is
| used to read data in the Request message, which is exposed as a Collection
| of name/value pairs in the object. The Request can include either URL query
| string variables (e.g. http..../somepage.asp?name=value) and form field
| values, when a form is submitted (form field name, and form field value), or
| both. This data is obtained using the syntax:
|
| value = Request(name)
|
| A variable is a storage container for data. You put data into the container
| by assigning it using the '=' character:
|
| variableName = Request(name) (puts the value from Request(name) into the
| variable "variableName")
|
| Now, in order to continue, I need to explain a little about the Response
| object. An HTTP Response is a text message that includes an HTML document.
| It is *written* to a stream that is sent to the browser. So, the chief
| method of the Response object is Response.Write, which writes to the output
| stream. The location in the page determines where that value will be
| inserted. As HTML is written directly, and interspersed with ASP code, the
| ASP code can write stuff among and between the HTML being sent. A typical
| Response.Write statement might look like the following (shown inside ASP
| tags):
|
| <%Response.Write("Hello World")%>
|
| However, there is also a *shorthand* notation for Response.Write, which is
| the '=' character. The following example writes the same as the previous:
|
| <%="Hello World"%>
|
| Now, if that piece of script were inside the <title> tag of an ASP page, as
| in:
|
| <title><%="Hello World"%></title>
|
| The HTML document on the client would have:
|
| <title>Hello World</title>
|
| So, putting it all together, you have ASP code written by the DBRW, which
| does all this for you. If you want to put in a value from a form field that
| posted to your results page, you would put:
|
| <%=Request("formFieldName")%>
|
| If it is a variable, you would put:
|
| <%=variableName%>
|
| Note the difference in the quoting. In the first example, you are referring
| to a member of a Collection by its name. In the second, you are referring
| directly to the contents of a variable with the name "variableName". In
| essence, you treate the variableName as if it were the data that is
| contained in the variable.
|
| --
| HTH,
|
| Kevin Spencer
| Microsoft MVP
| Professional Numbskull
|
| Show me your certification without works,
| and I'll show my certification
| *by* my works.
|
| | > Hi Kathleen, sorry Im still struggling with this one. I have created a
| > white
| > label test page at http://www.surproperties.com/asp/test2.asp?id=1532 ,
| > hope
| > this is helpful.
| > What Im trying to achieve, is when selecting a specific property using the
| > ID field (Im ok with that one, in this case 1532) is for the ASP to pick
| > up
| > the "Location" field from the DBRW results and display the "location"
| > field
| > within the page title, so the page title reads "Your Property in
| > "Location""
| > rather than what is typed between the <title> tags, so the <title>tag
| > changes
| > dynamically with each value from the "location" field. So property in this
| > case 1532 is in Playa de Las americas, and the page title would read
| > property
| > "Your Property in Playa de las Americas" and 1531 is in Fanabe, so the
| > title
| > would then read "Your Property in Fanabe".
| > Thanks again for your help and interest.
| >
| > "Kathleen Anderson [MVP - FrontPage]" wrote:
| >
| >> Yes. Assuming "entity" is your search field;
| >>
| >> <% strTitle = Request("entity")%>
| >> <head>
| >> <title>About the East Hampton <%=strTitle%> and Membership List</title>
| >>
| >> See: http://www.easthamptonct.org/bcc/boards/index.asp for an example;
| >> click
| >> on Town Council.
| >>
| >>
| >> --
| >>
| >> ~ Kathleen Anderson
| >> Microsoft MVP - FrontPage
| >> Spider Web Woman Designs
| >> web: http://www.spiderwebwoman.com/resources/
| >>
| >>
| >> | >> > Is it possible to use a field from the results from a DBRW to
| >> > dynamically
| >> > change the <title> tag in an asp please. Instead of every results page
| >> > from
| >> > the DBRW having the same <title> I want to pick up one field from the
| >> > DBRW
| >> > and replace it. I suspect the answer already, however its worth
| >> > asking...
| >> > many thanks
| >>
| >>
| >>
|
|
 
K

Kevin Spencer

Hi Stefan,

Stefan B Rusynko said:
Good explanation but doesn't solve the OP's problem (-;

I wasn't trying to solve the OP's current problem, only to help him with any
future problems he may have to solve by adding some technical underlying
information. I thought Kathleen was doing a fine job of helping him with his
current problem. :-D

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 

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

Top