homepage Welcome to WebmasterWorld Guest from 54.167.249.155
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Need Help with Title Tags in ASP Anyone?
dynamic title in ASP page
njabe567




msg:3334664
 8:58 am on May 9, 2007 (gmt 0)

My site was written in ASP , I have no issue changing the titles in many of my pages however I have many thousands of different "product" listings for example http://www.example.com/pro_details.asp?id=22307 ... now the issue is on google the title is the same for each one of my products when in fact they are different. SO my request is quite simple, how can I have the server pull a variable from the body and duplicate it in the title?

For instance the site now will pull up a category for the page to display.. lets say it pulls up the category "seafood" ..it displays the category in the body and all is well but if I try to copy and paste that into the title it doesn't work and I get an error. so I tried putting the <%=rs("category") %> into the title but to no avail.

Also the ASP code is all under the title tags if that means anything..i tried switching the position of the title tag to go under the ASP query string etc.. but that didn't work eiither... IM NO asp whiz but any tips would be appreciated.

I wold post the code for the ASP page but dont know if thats allowed?

 

mole




msg:3334723
 11:15 am on May 9, 2007 (gmt 0)

This works for me - an excerpt from a page with a title that is dynamically generated (about makes & model of different sorts of widgets)

<head>
<% response.write("<title>" & Make & " " & Model & " details</title>") %>

mattur




msg:3334788
 12:38 pm on May 9, 2007 (gmt 0)

Hi njabe567,

From your description, your ASP code is below the body tag. ASP code is processed inline, top to bottom, in source order.

You can't use any variables or data in the ASP code before the code has actually run, so you need to re-arrange your ASP/HTML to put the connection and recordset opening bits of the ASP code above the title element.

If you want to post a short, relevant excerpt of your code so someone can assist you further, you can do so - just don't post the whole page!

njabe567




msg:3336252
 8:25 pm on May 10, 2007 (gmt 0)

I see so I must do some re arranging,

<td class="searchfields" width=8 background=./images/det_midlft.gif><img height=1
src="./images/pixel-clr.gif" width=8></td>
<td class="searchfields" width="310"><b><% if session("frontuserid") <> "" then %><%=rs("address") %>,&nbsp;<% end if %><%= rs("area") %>,
<%= rs("city") %> - $<%= Currency_Format_Function(rs("rent")) %>/Mo.</b></td>
<td class="searchfields" width="239">
<div align="right"><img src="./images/printer.gif" style="cursor:hand" onClick="printpage()" width="15" height="20" align="absmiddle">
<A onClick="printpage()" style="cursor:hand">Print Page</a> &nbsp;&nbsp;&nbsp;<A href="email_to_friend.asp?id=<%= request("id") %>"><img border="0" src="./images/email.gif" width="16" height="16" align="absmiddle"></a>

<%=rs("address") %> .. that it what I want to be pulled into the title

<edited>

I would want that in the title. Is the only way to accomplish this is by rearranging the code as stated earlier?

<Sorry, no keywords or links.
See Forum Charter [webmasterworld.com]>

[edited by: tedster at 9:13 pm (utc) on May 10, 2007]

mattur




msg:3337094
 3:30 pm on May 11, 2007 (gmt 0)

Hi njabe567,

You need to find the bit of your ASP code where the connection and recordset are opened: it may be in the page higher up than your excerpt, or in an include file.

The code will include something like:

Set Something = Server.CreateObject("ADODB.Connection")

(search for the second bit "ADODB.Connection")

It should be a quick, straightforward job for a programmer to implement what you're looking for, so it may be easier to get your web developer to do it if you're unfamiliar with programming. HTH.

Joff




msg:3342820
 9:27 am on May 18, 2007 (gmt 0)

Hi njabe,

As mattur's said, it should be a really quick change for someone to do. Worst case, rearrange your code logic so the recordset is opened (and closed) before you start using any HTML, instead using variables to contain the values you want from the DB.

Eg.

<%
open recordset

Dim sAddress
sAddress = oRS("address")
sArea = oRS("area")
sCity = oRS("city")
iID = oRS("id")
cRent = oRS("rent")

close recordset
%>
<html>
<head>
<title><%=sAddress%></title>
</head>
...

<td class="searchfields" width=8 background=./images/det_midlft.gif>
<img height=1
src="./images/pixel-clr.gif" width=8>
</td>
<td class="searchfields" width="310">
<b><% if session("frontuserid") <> "" then %><%=sAddress%>,&nbsp;<% end if %><%=sArea%>,
<%=sCity%> - $<%= Currency_Format_Function(cRent) %>/Mo.</b>
</td>
<td class="searchfields" width="239">
<div align="right"><img src="./images/printer.gif" style="cursor:hand" onClick="printpage()" width="15" height="20" align="absmiddle">
<A onClick="printpage()" style="cursor:hand">Print Page</a> &nbsp;&nbsp;&nbsp;
<A href="email_to_friend.asp?id=<%=iID%>"><img border="0" src="./images/email.gif" width="16" height="16" align="absmiddle"></a>

...
</html>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved