Click to See Complete Forum and Search --> : Two very differerent coding forms : merge?


WolfShade
01-19-2006, 01:00 PM
I've got a question about page indexing and ASP.

I'm trying to upgrade the look/feel of an existing site in which much of the code is totally foreign to the way I was taught ASP classic. In particular is the News section; here's a sample of the code:


<%
Call getDoc(11, 0, dctDoc)
%>
<%if CInt(cid) <= 0 then%>
<tr>
<td valign=top class="menu1">
<b><a href="default.asp?page=<%= page %>" style="color:#696969;" onMouseOver="window.status='';return true;"><% 'response.write(toHTML(dctDoc("SUBTITLE")))%></a></b>
</td>
</tr>
<tr bgcolor=ffffff><td><img src="./images/spacer.gif" width=1 height=5 border=0></td></tr>
<%end if%>
<tr>
<td valign=top class="menu1">
<%if CInt(cid) <= 0 then%>
<%' response.write(dctDoc("SUMMARY"))%>
<% SELECT CASE lcase(page) %>
<% case "events" %>
Welcome to the Tech Lighting events center. This is your online resource for information
of shows you can visit us at.
<% case else %>
<% END SELECT %>
<%
'dim args, retval, docs, p
set args = ap20_initArgs()
args("TYPE") = subpageDisplay
args("SORT") = SORT_DESCENDING
args("MODE") = MODE_NEWER
args("DATE") = "1/1/1998"
args("DID") = cid
args("MAX") = 10
args("PAGESIZE") = 10
args("AUTHOR") = -1
set docs = ap20_getList(args, retval)

'if retval("COUNT") > 0 then
IF page = "events" then
while ap20_more(docs)
%>
<p><span class="menu1">
<!--<strong><%=FormatDateTime(toHTML(docs("doc_begindate")), vbShortDate)%></strong><br /><b><span class="tiny"><%=docs("doc_title")%></span></b>-->
<%=docs("doc_summary")%>
</span></p>
<%
ap20_next(docs)
wend
%>
<% ELSE
while ap20_more(docs)
%>
<p><span class="menu1">
<strong><%=FormatDateTime(toHTML(docs("doc_begindate")), vbShortDate)%></strong><br /><a href="./default.asp?page=<%= page %>&cid=<%=docs("doc_id") %>" class="tiny" style="color:#696969;text-decoration:none;" onMouseOver="window.status='';return true;"><b><span class="tiny"><%=docs("doc_title")%></span></b></a>
<%=Left(docs("doc_summary"), 150)%> <%if Len(docs("doc_summary")) > 150 then Response.Write "..."%> <b><a href="./default.asp?page=<%= page %>&cid=<%=docs("doc_id") %>" class="tinyOrange" style="text-decoration:none;" onMouseOver="window.status='';return true;"><span class="tinyOrange">[more]</span></a></b>
</span></p>
<%
ap20_next(docs)
wend

END IF
'end if 'if no serach results
ap20_destroy args
%>
<%end if%>
</td>
</tr>


^ That's the code that is foreign to my development training.


I found a decent code for page index and navigation, but I can't figure out how to merge the two together:

<%

Con.Open Application.Value("connStr")

'Need a rich cursor type to support paging
rsPage.CursorType = 3 'adOpenStatic

'Open recordset
rsPage.Open lsSQL, Con
IF not rsPage.BOF AND not rsPage.EOF then
IF trim(request.querystring("sa")) = "va" then
sa = 0
'Set the number of records in each page to 9
rsPage.PageSize = rsPage.RecordCount

'Set the current page based on the QueryString value
'Must cast it as an integer or else it will have problems.
rsPage.AbsolutePage = 1

ELSE

'Set the number of records in each page to 9
rsPage.PageSize = 12

'Set the current page based on the QueryString value
'Must cast it as an integer or else it will have problems.
rsPage.AbsolutePage = cInt(sa)

END IF
End IF

%>
<% IF rsPage.RecordCount > rsPage.PageSize then %>
<% If Response.IsClientConnected = true then
bpage = sa - 1
IF bpage <= 0 then bpage = rsPage.PageCount
npage = sa + 1
IF npage > rsPage.PageCount then npage = 1
Response.Write(" <a href='default.asp?page=products&subpage=systemcompat&sysid=" & sysid & "&cls=" & cls & "&nme=" & nme & "&sa=" & bpage & "' class='BodyParagraph'><u>«</u></a> ")
For PageCounter = 1 to rsPage.PageCount
bOpen = ""
bClose = ""
IF CInt(PageCounter) = CInt(sa) then
bOpen = "<b>"
bClose = "</b>"
End IF
Response.Write " <a href='default.asp?page=products&subpage=systemcompat&sysid=" & sysid & "&cls=" & cls & "&nme=" & nme & "&sa=" & PageCounter & "' class='BodyParagraph'><u>" & bOpen & PageCounter & bClose & "</u></a> "
Next
Response.Write(" <a href='default.asp?page=products&subpage=systemcompat&sysid=" & sysid & "&cls=" & cls & "&nme=" & nme & "&sa=" & npage & "' class='BodyParagraph'><u>»</u></a> ")
END If
%>
<input name="viewalla" type="image" class="tiny" onClick="window.location='default.asp?page=products&subpage=systemcompat&sysid=<%= sysid %>&cls=<%= cls %>&nme=<%= nme %>&sa=va';" value="View All" src="images/ViewAll.JPG" alt="View All" />
<% end IF %>



Any ideas? The function that is called for the news query is an include, and the data connection is closed at this point.

WolfShade
^_^
.

Ubik
01-19-2006, 03:22 PM
All I can say is that the first bunch of code is the most horrible asp code I've ever seen.

My idea: "I say we take off and nuke the entire site from orbit. It's the only way to be sure."

WolfShade
01-23-2006, 12:46 PM
All I can say is that the first bunch of code is the most horrible asp code I've ever seen.


Oh, I know. Makes my eyes cross just thinking about looking at it; but it's not mine, thankfully, it belongs to the guy who originally designed the site, and I didn't have time to do it from scratch, so I used his code. This was before the client wanted to limit the initial display to only two 'blurbs' which when clicked will go to the article.

So there's nothing that can be done?

WolfShade
^_^
.

russell_g_1
01-23-2006, 03:56 PM
it's not that bad. depends what exactly he was trying to do doesn't it? and i've seen a lot worse from people on this site.