Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Binding to the LINK field in ASP

New Here ,
Jan 08, 2009 Jan 08, 2009

Copy link to clipboard

Copied

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)
TOPICS
Server side applications

Views

367
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 08, 2009 Jan 08, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2009 Jan 08, 2009

Copy link to clipboard

Copied

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>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 08, 2009 Jan 08, 2009

Copy link to clipboard

Copied

LATEST
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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines