Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 26th, 2012, 05:43 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Gaps in code when checking View Source?

When we view a classic ASP page of ours in View Source there are gaps appearing in the HTML code, for example this...

<html>
<head>
<%
If not(RS.EOF) Then
RS.move lowcounter
counter = lowcounter
if keyword <> "" and not(rs.eof) then
%>
<title>Children's <%=keyword%> Resources: <%=keyword%> Quick Info, Educational <%=keyword%> Facts, <%=keyword%> related Articles</title>
<meta name="description" content="<%=keyword%>, <%=RS("tags")%>,Popular References for '<%=keyword%>', Fun Learning for Students, '<%=keyword%>' related Activities for Kids, School Fun Activities, '<%=keyword%>' Info Online">
<meta name="keywords" content="Best <%=highcounter%> References for '<%=keyword%>', School '<%=keyword%>' theme Activities, Online '<%=keyword%>' Facts, Popular References for '<%=keyword%>', Online Articles for Children,'<%=keyword%>' related Activities for Kids, School Fun Activities, '<%=keyword%>' related Facts,<%=RS("tags")%>">
<%
metawritten = "Y"
end if
'================================================= ==========
' Start a new IF as meta tags are already written above
' and these were repeated again
If metawritten <> "Y" and not(rs.eof) Then
'================================================= ==========
pagenum = highcounter/10
catNameRaw = RS("category")
if pagenum>1 then metaTitle = "Page " & pagenum & ": "
metaTitle = metaTitle & Replace(catNameRaw, "_", " ")
%>
<%
Select Case catNameRaw
Case "Articles"
metaDesc = "Listing of Articles on Juniors Book, Family Dynamics, Raising Skills, Behavior and Development, Education and Learning, Information for Parents"
Case "News 4 Kids"
metaDesc = "Listing of News 4 Kids on Juniors Book, Recent News, Odd and Weird News, Current Events, News Bulletin, News Bites, Online Edition"
Case "Tell Me Why"
metaDesc = "Listing of Tell Me Why on Juniors Book, Featured Questions, Educational Questions with Answers, Questions Kids Ask, Frequently asked Questions"
Case "This Happened To Me"
metaDesc = "Listing of This Happened To Me on Juniors Book, Experiences of Life, Conditions and Circumstances, Life is Like That"
Case "Funky Stories"
metaDesc = "Listing of Funky Stories on Juniors Book, Stories Online, Story Time, Moral Stories, Fables and Folktales, Collection of Stories"
Case "Travel The Great States"
metaDesc = "Listing of Travel The Great States on Juniors Book, Road Trips, United States Tour and Travel, American Vacations, Discover America"
Case "Games"
metaDesc = "Listing of Games on Juniors Book, Outdoor Games, Educational Games, Games Kids Play, Instructional Games"
Case "Optical Illusion"
metaDesc = "Listing of Optical Illusion on Juniors Book, Optical Illusions, Visual Phenomena, Visually Perceived Objects and Images"
Case "Thinking Skills"
metaDesc = "Listing of Thinking Skills on Juniors Book, Thinking Techniques with Images, Logical Thinking, Critical Thinking, High Probability Thinking, Lateral Thinking, Low Probability Thinking, Sneaky Thinking"
Case "Whodunit"
metaDesc = "Listing of Whodunit on Juniors Book, Detective Fiction, Story Contest, Armchair Detectives, Clue Finders"
Case Else
metaDesc = "Other Pages for " & catNameRaw
End Select
%>
<title><%=metaTitle%> on Junior's Book</title>
<meta name="description" content="<%Response.Write(metaDesc)%>">
<meta name="keywords" content="<%=RS("title")%>:<%=Replace(catNameRaw, "_", " ")%> for <%=Replace(RS("country"), "_", "")%> Kids in <%=Replace(RS("city"), "_", " ")%>: <%=RS("subtitle")%>,<%=RS("tags")%>,<%=Replace(RS( "country"), "_", "")%> Popular <%=Replace(catNameRaw, "_", " ")%>">
<%
'================================================= ==========
' Start a new IF as meta tags are already written above
' and these were repeated again
End If
'================================================= ==========
else
%>
<title>Sorry - No related activity worksheets found! Free PDF format Printable activity Work books,Download free of cost Fun Games for Kids, Learning activity sheets in PDF format,Printable Fun Learning Games</title>
<meta name="description" content="No related Activity Sheets Found,Free activity Sheets for small kids,Learning games online,Free downloadble activity books, Sorry - No related activity worksheets found! Free PDF format Printable activity Work books,Download free of cost Fun Games for Kids, Learning activity sheets in PDF format,Printable Fun Learning Games">
<meta name="keywords" content="Sorry - No related activity worksheets found! Free PDF format Printable activity Work books,Download free of cost Fun Games for Kids, Learning activity sheets in PDF format,Printable Fun Learning Games">
<%
end if
%>
<meta http-equiv="Content-Language" content="EN">


...is appearing as this in View Source:

1
2 <html>
3 <head>
4
5 <title>This Happened To Me on Junior's Book</title>
6 <meta name="description" content="Listing of This Happened To Me on Juniors Book, Experiences of Life, Conditions and Circumstances, Life is Like That">
7 <meta name="keywords" content="A Big Wake-up Call for Me!:This Happened To Me for Kids in : I picked up a gallon of apple juice at local grocery, and on side of the jug it said, Contains Concentrate from China. What the heck...,Big Wake up Call, Made in USA, Tools and kitchenware, Trinkets, Christmas Pajamas, Hanes Sweatshirts, Turtleneck Shirts, JC Pennys Online Catalog, Flip Flops, Popular This Happened To Me">
8
9 <meta http-equiv="Content-Language" content="EN">

Why are there blank lines appearing at lines 1, 4 and 8 in our code?

Appreciate any help offered. Thank you.
NJ
Reply With Quote
  #2 (permalink)  
Old November 26th, 2012, 08:41 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

these spaces might appear due to the large chunk of ASP code. one option is to store these values in variable and later create HTML content and assign these variables in HTML.
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
Reply With Quote
  #3 (permalink)  
Old November 26th, 2012, 05:50 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes I would say OM is correct its becasue your code is all over the place, its messy, repetitive........I could go on....

Oh also you should indent your code. Have a read up on this, it will make yours and other people on forums life a lot easier!!!

IMO you should start agin with this page. Place your ASP at the top, create variables, populate them, then write your HTML using the variables. You should only have one <title>, <meta...., <head> and <head> tags. here is an example of what I mean:

Code:
<%
dim titleContent, metaDesc, metaKey
if somevalue = someValue then
   titleContent = "..."
   metaDesc = "..."
   metaKey = "..."
elseif someValue = someOtherValue then
   titleContent = "..."
   metaDesc = "..."
   metaKey = "..."
elseif someValue = andAnotherValue then
   titleContent = "..."
   metaDesc = "..."
   metaKey = "..."
end if
%>
<html>
 <head>
  <title><%= titleContent %></title>
  <meta name="description" content="<%= metaDesc %>">
  <meta name="keywords" content="<%= metaKey %>">
 </head>
 <body>
   the page content here of course
 </body>
</html>
Hope that helps
__________________
Wind is your friend
Matt
Reply With Quote
  #4 (permalink)  
Old November 27th, 2012, 01:39 PM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Humble apologies...

Firstly, sorry about not indenting the code. Duly noted.

Unfortunately, I have inherited this code and have been asked to clean it up, although my knowledge of Classic ASP isn't great.

I would agree that it's a mess though!

I'll have a go at rebuilding it, using your advice on variables, and we'll see if that resolves things. I am, however, deeply confused by what's in the header at the moment.

If you could offer any advice on that, I'd be very grateful. Thank you.

Regards
NJ.
Reply With Quote
  #5 (permalink)  
Old November 27th, 2012, 05:30 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

no need to be sorry, am happy to give you my opinion....

BTW I don't know why you are getting the line breaks. I suspect its something to do with the state of the code in general....

I dont know what you mean when you say 'confused by what's in the header at the moment.' whats in the header?
__________________
Wind is your friend
Matt
Reply With Quote
  #6 (permalink)  
Old November 29th, 2012, 10:44 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt,

Sorry, I meant the code posted in my original post.

This is what appears above the head section:

Code:
<%
Dim currentcount, totalcount, counter, lowcounter, highcounter
todo = Request("do")
counter=0
lowcounter=Request ("counter")
currentcount = lowcounter

IF currentcount = "" then
currentcount = 1
else
currentcount = lowcounter+1
end if
IF lowcounter="" Then
lowcounter=0
End IF
highcounter=lowcounter+10
lowcounter=highcounter-10
errormsg = Replace(Request("errormsg"), "_", " ")
category = Replace(Request("category"), "_", " ")
keyword = Replace(Server.HTMLEncode(Trim(Request("keyword"))), "_", " ")
city = Replace(Request("city"), "_", " ")
country = Replace(Request("country"), "_", " ")
mySQL = "SELECT * FROM article WHERE admincheck = true"
if category <> "" AND category <> "Select" then
mySQL = mySQL & " AND category = '"& category &"' "
end If
if city <> "" then
mySQL = mySQL & " AND city = '"& fixQuotesQ(city) &"' "
end If
if country <> "" then
mySQL = mySQL & " AND country = '"& fixQuotesQ(country) &"' "
end If
if keyword <> "" then
mysql = mysql & " AND (title Like '%" & fixQuotesQ( keyword ) & "%'"
mysql = mysql & " or subtitle Like '%" & fixQuotesQ( keyword ) & "%'"
mysql = mysql & " or story Like '%" & fixQuotesQ(keyword) & "%'"
mysql = mysql & " or author Like '%" & fixQuotesQ(keyword) & "%'"
mysql = mysql & " or keyword Like '%" & fixQuotesQ(keyword) & "%'"
mysql = mysql & " or sourceurl Like '%" & fixQuotesQ(keyword) & "%'"
mysql = mysql & " or tags Like '%" & fixQuotesQ(keyword) & "%')"
end if
mySQL = mySQL & " ORDER BY entrydate DESC"
Set RS = Server.CreateObject("ADODB.Recordset")

Set RS = Con.Execute( mySQL)
If (RS.EOF) Then
Response.Status = "404 Not Found"
End If
%>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15 source code will not open in design view Michael Grimes BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 2 April 6th, 2018 04:06 PM
Design view or source view tab doesnt appear Muddasar BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 March 25th, 2009 04:16 AM
Design view or source view tab doesnt appear Muddasar BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 0 March 24th, 2009 08:18 PM
Unable to view source code! yuvin ASP.NET 1.0 and 1.1 Basics 0 January 10th, 2007 02:00 AM
Using an ear file to view source code amerwaip J2EE 1 July 21st, 2005 11:05 AM



All times are GMT -4. The time now is 05:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.