Posts filed under 'ASP'

Nested Repeat Regions in ASP

Here some code and a tutorial on how to create a nested repeat region in ASP:-

http://www.donenet.co.uk/tutorials/nested%5Frepeat/nested%20repeat.html

The Code:-

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/connDN.asp" -->
<%
Dim rsNewsletter
Dim rsNewsletter_numRows

Set rsNewsletter = Server.CreateObject("ADODB.Recordset")
rsNewsletter.ActiveConnection = MM_connDN_STRING
rsNewsletter.Source = "SELECT *  FROM tblNewsletter  ORDER BY NLID ASC"
rsNewsletter.CursorType = 0
rsNewsletter.CursorLocation = 2
rsNewsletter.LockType = 1
rsNewsletter.Open()

rsNewsletter_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsNewsletter_numRows = rsNewsletter_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nested Repeat Region</title>
</head>

<body>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsNewsletter.EOF))
%>
<%
Dim rsNewletterTopic__varNLID
rsNewletterTopic__varNLID = "0"
If (rsNewsletter("NLID") <> "") Then
  rsNewletterTopic__varNLID = rsNewsletter("NLID")
End If
%>
<%
Dim rsNewletterTopic
Dim rsNewletterTopic_numRows

Set rsNewletterTopic = Server.CreateObject("ADODB.Recordset")
rsNewletterTopic.ActiveConnection = MM_connDN_STRING
rsNewletterTopic.Source = "SELECT *  FROM tblNewsletterTopic  WHERE NLID = " + Replace(rsNewletterTopic__varNLID, "'", "''") + ""
rsNewletterTopic.CursorType = 0
rsNewletterTopic.CursorLocation = 2
rsNewletterTopic.LockType = 1
rsNewletterTopic.Open()

rsNewletterTopic_numRows = 0
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
rsNewletterTopic_numRows = rsNewletterTopic_numRows + Repeat2__numRows
%>
  <%=(rsNewsletter.Fields.Item("NLTitle").Value)%><br />
<%
While ((Repeat2__numRows <> 0) AND (NOT rsNewletterTopic.EOF))
%>
  <%=(rsNewletterTopic.Fields.Item("NLTName").Value)%><br />
  <%
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  rsNewletterTopic.MoveNext()
Wend
%> 
<br />
<%
rsNewletterTopic.Close()
Set rsNewletterTopic = Nothing
%>
<%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsNewsletter.MoveNext()
Wend
%>
</body>
</html>
<%
rsNewsletter.Close()
Set rsNewsletter = Nothing
%>

Hope it all makes sense…


Add comment April 8, 2007

Merry Xmas

Merry Xmas everyone, my New Years resolution will be to try and post more often.  I will try and get some ASP stuff together but am struggling for ideas at present, so if you guys think of anything let me know and I’ll see what I can do.

Idea’s on the back of a postcard to http://donenet.wordpress.com… LOL


1 comment December 21, 2006

Site Relaunched

New Look Site

Ok I know I haven’t been posting a lot lately but I have plenty of excuses, one of them is the re-launch of the DoneNet website - www.donenet.co.uk.  The main reson for the change was to conform to DDA (Disability Discrimination Act) standards, using XHTML and CSS and to get rid of all those horrible tables.  The technology used was as follows:-

  • ASP
  • MS Access
  • XHTML
  • CSS
  • AJAX (See Examples Section)

I am looking to push for new projects in New Year; I have 2 on the go at present, one for a law firm which will be launching in January and the other being a community based website for my local community council.

If you have any comments on the new look Donenet site please let me know? 


1 comment December 21, 2006

Working with variables in ASP

OK here's a short one, this example shows you how do the basics with variables, it demonstrates how to do a simple bit of maths on a shopping cart.
<%

dim vCART,vSHIPPING,vTOTAL

vCART = 47.99 'this variable would hold the total cart price including VAT, you would probably hold this information in a session variable but for this example I have hard coded the price in

vSHIPPING = 3.99
vTOTAL = vCART+vSHIPPING 'this variable will give the total price including shipping

%> 

To write the total out on the web page all you have to do is:-

<%=vTOTAL%> 

And thats it. 


2 comments June 21, 2006

Show and hide elements with ASP

This trick will help may of the readers of this blog hide and show elements of a page or even run commands when a certain event happens.

you can do this by either passing the event trigger via a form event or a query string, in this instance we are going to do it by way of a query string.

The example we will use is a simple question and answer (What does ASP stand for), the code below is commented so it should be straight forward to understand.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Show and hide elements with ASP - by Robbie Done</title>
</head>
<body>

What does ASP stand for?<br />

<ol>
<li><a href="?answer=w">A Super Person</a> <!–This line passes a query string back to this page, note that it woll pass ("?answer=w")–>
<li><a href="?answer=c">Active Server Pages</a> <!–This line passes a query string back to this page, note that it woll pass ("?answer=a")–>
<li><a href="?answer=s">Altitude Sensory Paddle</a> <!–This line passes a query string back to this page, note that it woll pass ("?answer=s")–>
</ol>
<br />
<%
If Request.QueryString("answer&quot ;) <> "" Then 'The answer script is not called untill one of answers has been selected, it is basically saying in english - if the query string called answer is not equal to nothing then do this…
If Request.QueryString("answer&quot ;) = "w" Then
Response.Write("Wrong Answer!"&"<br /><br />&quot ;)
Else If Request.QueryString("answer&quot ;) = "c" Then
Response.Write("You Are Correct"&"<br /><br />&quot ;)
Else Response.Write("Are You Kidding? Try Again!"&"<br /><br />&quot ;) 'This line of code is not like the above 2 request because if we know the query string is not equal to w nor c then it must be the remaining one of the 3
End If
End If
End If 'End of answer script
%>
<a href="?">Reset</a>
<!–This hyperlink will reset the page as it does not contain a querystring –>
</body>
</html>

And that's how easy it is to show and hide elements using ASP.


Add comment June 19, 2006

ASP display year

Ok, how many of websites you visit and you see something like this at the bottom of the page where the copyright link is:-

© company name 1996 - 2003

Well they are 3 years out of date and there's no excuse whether the site is in HTML, ASP, PHP etc. There are ways to make it dynamic in all of these languages, so I'm going to show you how to do it in ASP right now…

© company name <%=year(now)%>

or if you want to do it the long winded way by the book:-

© company name <%response.write(year(now))%>

Notice in the first example = works the same as writing response.write

There it is making your copyright statements dynamic in ASP.


Add comment June 17, 2006


Calendar

August 2008
M T W T F S S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031

Posts by Month

Posts by Category