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

Tagged By Moody

He he Moody you finally got me to make a post…..

Heres the rules——

  • Grab the closest book to you
  • Open Page 123
  • Scroll down to the 5th sentence
  • Post the next 3 sentences on your blog
  • Name the book and author
  • Tag 3 people

—————————————–

As with the cookies collection, redirection, and buffering, we must add headers befor the server parses the <HTML> tag in our Active Server Pages.

To allow proxy servers to cache output, generated by our ASP pages, we can use the cachecontrol property.

This property can have two values-public or private.  If the value of this property is public, the output will be caqched by proxy servers.

—————————————–

Name of book:- Professional  Active Server Pages 2.0 by Wrox

—————————————–

I Tag:

  1.  Twilight Town
  2. D.a.double-r.e.n
  3. kevdotbadger

Get blogging people…..

Hey Moo, the  persistant nagging paid of…. LOL

1 comment December 21, 2006

It’s been a while

It’s been a while since my last post but I was gutted when England were dumped out of the world cup, but look out i’m back and i’m gonna be doing some more ASP (any suggestions?)

3 comments August 2, 2006

We’re Out Boo Hoo

Well it finally happened on Saturday, the bloody lucky cheating  Portuguese gets knocked us out on penalties.  I havn’t been able to sit at a computer since due to the agony of the coverage on the web….

Well I’m back now and looking forward to Euro 2008, we have a good chance as the group is a fantastic draw for us.

I will be developing some new ASP tips and tricks very soon and will probably theme them around footie, if you have any requests then drop me a comment or e-mail…

6 comments July 4, 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. 

3 comments June 21, 2006

What an amazing goal

Joe Cole Goal (Amazing)Joe Cole played excellent tonight, on occasions I have thought he had hung on to the ball for far too long, and that he should pass it to the overlapping player (A. Cole).

But tonight the guy could not be faulted, he was on fire.

The goal he scored was struck with pure destiny for the back of the net, it must be up there for the goal of the tournament.

Another player that shone tonight was Owen Hargreaves, his work rate was unbileavable, he realy covered well for Lampard when he was getting forward.

Well we're through to the last 16 now and it's Ecuador next, all we have to do till then is practice the defending set pieces and get through to the last 8.

1 comment June 20, 2006

Come on ENGLAND!

I hope England give those Swedes a good mashing tonight, now that it looks like Rooney will start we should be able to play properly.

My prediction for tonight is – England 3 – Sweden 1

Add comment June 20, 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") <> "" 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") = "w" Then
Response.Write("Wrong Answer!"&"<br /><br />")
Else If Request.QueryString("answer") = "c" Then
Response.Write("You Are Correct"&"<br /><br />")
Else Response.Write("Are You Kidding? Try Again!"&"<br /><br />") '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

Previous Posts


Categories

  • Blogroll

  • Feeds