ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





ASP Source Code:
<%
Dim strScriptName
Dim arrPhotoNames
Dim arrPhotoTitles
Dim intPhotoId
Dim I
' Get script URL for links
strScriptName = Request.ServerVariables("URL")
' You'd probably get this info from a database or an XML file or
' something like that, but the source will vary based on your
' situation so I'm just loading the array manually.
arrPhotoNames = Array("09922491", "09999118", "10047069", "19079112", _
                      "19124507", "19151069", "19297986", "22474694", _
                      "22475208", "24231229", "30423914", "31931795")
arrPhotoTitles = Array("Freeway", "Symbology", "Ladies Night", _
                       "You Are So Fired", "A Charming Hangover", _
                       "Pay the Man", "Give Yourself A Hand", _
                       "Stack", "The Office", "aVoid", _
                       "Spring Into Action", "Home Improvement")
intPhotoId = Request.QueryString("photo")
If intPhotoId <> "" Then
    intPhotoId = CInt(intPhotoId)
    If intPhotoId < LBound(arrPhotoNames) Or intPhotoId > UBound(arrPhotoNames) Then
        intPhotoId = -1
    End If
Else
    intPhotoId = -1
End If
If intPhotoId = -1 Then
    ' Show Gallery
    Response.Write "<h2>Photo Gallery</h2>" & vbCrLf
    Response.Write "<table border=""1"" cellspacing=""0"">" & vbCrLf
    Response.Write "<tr>" & vbCrLf
    For I = LBound(arrPhotoNames) To UBound(arrPhotoNames)
        ' Show each thumbnail in it's own table cell
        Response.Write "<td valign=""top"" align=""center"">"
        Response.Write "<a href=""" & strScriptName & "?photo=" & I & """>"
        Response.Write "<img src=""photos/" & arrPhotoNames(I) & ".thm.jpg"""
        Response.Write "border=""0"" /></a><br />"
        Response.Write "<font size=""-1"">" & arrPhotoTitles(I) & "</font>"
        Response.Write "</td>" & vbCrLf
        ' Start a new row every 4 thumbnails.
        ' In the Mod line below, the 4 is because we want 4 thumbnails
        ' per row and the 3 is because we started counting from 0.
        ' If you want more or less columns just adjust accordingly:
        '  I Mod [Columns] = [Columns - 1]
        'If I Mod 4 = 3 Then
        ' I actually changed it so that we're only showing 2 images across
        ' to deal with the images overlapping with our flex ads.
        If I Mod 2 = 1 Then
            Response.Write "</tr><tr>" & vbCrLf
        End If        
    Next 'I
    Response.Write "</tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
Else
    ' Show Photo Detail
    Response.Write "<h2>Photo Gallery</h2>" & vbCrLf
    ' photo title
    Response.Write "<h3>" & arrPhotoTitles(intPhotoId) & "</h3>" & vbCrLf
    ' Show full photo image.
    Response.Write "<p>"
    Response.Write "<img src=""photos/" & arrPhotoNames(intPhotoId) & ".thw.jpg"""
    Response.Write "alt=""" & arrPhotoTitles(intPhotoId) & """"
    Response.Write "border=""0"" />"
    Response.Write "</p>" & vbCrLf
    ' previous and next links
    Response.Write "<p>"
    If intPhotoId > LBound(arrPhotoNames) Then
        Response.Write "<a href=""" & strScriptName
        Response.Write "?photo=" & intPhotoId - 1 & """>"
        Response.Write "<code><--</code> previous</a>"
    End If
    Response.Write "     "
    If intPhotoId < UBound(arrPhotoNames) Then
        Response.Write "<a href=""" & strScriptName
        Response.Write "?photo=" & intPhotoId + 1 & """>"
        Response.Write "next <code>--></code></a>"
    End If
    Response.Write "</p>" & vbCrLf
    Response.Write "<p>"
    Response.Write "<a href=""" & strScriptName & """>"
    Response.Write "Back to the Main Photos Page</a>"
    Response.Write "</p>" & vbCrLf
End If
%>
<p>
Thumbnails and photos from <a href="http://www.photos.com/">Photos.com</a>.
They have over 180,000 royalty-free stock photographs available by subscription.
</p>

Back the the Sample Output

Back to the Sample Index


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers