Skip to main content
Participating Frequently
January 8, 2009
Question

Binding to the LINK field in ASP

  • January 8, 2009
  • 3 replies
  • 382 views
Hi,
I've set up an ASP page that binds to a table containing image location, ALT text and URL link fields. I have inserted an image into a page and binded the link, alt and image location attributes to the above fields. I have then inserted a 'random record' server extension. This shows a random image with a random alt text every time the page is refreshed.

The only trouble is, the URL link is always the same. I can't seem to get this binded correctly to show the correct link.

Any suggestions or methods of how I can get this done?

Any help would be greatly appreciated 🐵
This topic has been closed for replies.

3 replies

Inspiring
January 8, 2009
kliq316 wrote:
> Here you go, the first part is the server extension that allows a random record
> to be displayed every time the page is refreshed. After that is the code for
> the image.
>
> <%
> ' Moving to random record - Steven Jones' Extension
> If Not(rsSplashImage.bof and rsSplashImage.eof) Then
> ' reset the cursor to the beginning
> If (rsSplashImage.CursorType > 0) Then
> rsSplashImage.MoveFirst
> Else
> rsSplashImage.Requery
> End If
>
> rsSplashImage_totalrn = -1
> rsSplashImage_totalrn = rsSplashImage.RecordCount ' ony works on some
> recordsets, but much faster
> If (rsSplashImage_totalrn = -1) Then ' and if it didn't work, we still have
> to count the records.
>
> ' count the total records by iterating through the recordset
> rsSplashImage_totalrn=0
> While (Not rsSplashImage.EOF)
> rsSplashImage_totalrn = rsSplashImage_totalrn + 1
> rsSplashImage.MoveNext
> Wend
>
> ' reset the cursor to the beginning
> If (rsSplashImage.CursorType > 0) Then
> rsSplashImage.MoveFirst
> Else
> rsSplashImage.Requery
> End If
>
> End If
>
> ' now do final adjustments, and move to the random record
> rsSplashImage_totalrn = rsSplashImage_totalrn - 1
> If rsSplashImage_totalrn > 0 Then
> Randomize
> rsSplashImage.Move Int((rsSplashImage_totalrn + 1) * Rnd)
> End If
> End If
> ' all done; you should always check for an empty recordset before displaying
> data
> %>
> <a href="<%=(rsSplashImage.Fields.Item("link").Value)%>"><img
> src="<%=(rsSplashImage.Fields.Item("imagesplash").Value)%>"
> longdesc="<%=(rsSplashImage.Fields.Item("alttext").Value)%>" /></a>
>

Is the page live? Do you have a link?

Dooza
kliq316Author
Participating Frequently
January 8, 2009
Here you go, the first part is the server extension that allows a random record to be displayed every time the page is refreshed. After that is the code for the image.

<%
' Moving to random record - Steven Jones' Extension
If Not(rsSplashImage.bof and rsSplashImage.eof) Then
' reset the cursor to the beginning
If (rsSplashImage.CursorType > 0) Then
rsSplashImage.MoveFirst
Else
rsSplashImage.Requery
End If

rsSplashImage_totalrn = -1
rsSplashImage_totalrn = rsSplashImage.RecordCount ' ony works on some recordsets, but much faster
If (rsSplashImage_totalrn = -1) Then ' and if it didn't work, we still have to count the records.

' count the total records by iterating through the recordset
rsSplashImage_totalrn=0
While (Not rsSplashImage.EOF)
rsSplashImage_totalrn = rsSplashImage_totalrn + 1
rsSplashImage.MoveNext
Wend

' reset the cursor to the beginning
If (rsSplashImage.CursorType > 0) Then
rsSplashImage.MoveFirst
Else
rsSplashImage.Requery
End If

End If

' now do final adjustments, and move to the random record
rsSplashImage_totalrn = rsSplashImage_totalrn - 1
If rsSplashImage_totalrn > 0 Then
Randomize
rsSplashImage.Move Int((rsSplashImage_totalrn + 1) * Rnd)
End If
End If
' all done; you should always check for an empty recordset before displaying data
%>
<a href="<%=(rsSplashImage.Fields.Item("link").Value)%>"><img src="<%=(rsSplashImage.Fields.Item("imagesplash").Value)%>" longdesc="<%=(rsSplashImage.Fields.Item("alttext").Value)%>" /></a>
Inspiring
January 8, 2009
kliq316 wrote:
> Hi,
> I've set up an ASP page that binds to a table containing image location, ALT
> text and URL link fields. I have inserted an image into a page and binded the
> link, alt and image location attributes to the above fields. I have then
> inserted a 'random record' server extension. This shows a random image with a
> random alt text every time the page is refreshed.
>
> The only trouble is, the URL link is always the same. I can't seem to get this
> binded correctly to show the correct link.
>
> Any suggestions or methods of how I can get this done?
>
> Any help would be greatly appreciated :o)

Can you post your code please?

Dooza