This snippet demonstrates a way to display a dynamically generated image so that it sits within dynamically generated text, using CSS and ASP VBScript. Easy enough to do with CSS and static text using 'Float' but it becomes a little more challenging when you have text being dynamically loaded from a database, particularly when the text can be a variety of lengths. This snippet first gets the length of the text, then calculates a 4th of that total, tho' you can change that if you want. The code will then put the picture into the body of the text and then print the remainder of the text.

Step 1

Set up your CSS style.

Code:

<style type="text/css">
<!--
.FloatPic {
float: right;
padding-top: 5px;
padding-left: 5px;
}
-->
</style>

Step 2

Set up your Record Set.

Step 3

Add this code inside the body tag:

<%
' ***set up your Vars
Dim strContent, strLength, strRemains, strStart
'***Get your text
strContent = rs_YourRecordSet.Fields.Item("YourTextField").Value

'***Get the length of the text
strLength = Len (strContent)
'***Divide the length by 4. This will be the top portion of text.
strStart = (strlength /4)
'***Calculate how much text is left to be display.
strRemains = (strLength - strStart+1)
'***Print the top portion of the text
Response.Write LEFT (strContent, strStart)
%>
<%
'***Check if there is an image to display, if there is then display it.
if (rs_YourRecordSet.Fields.Item("YourImageField").Value <> "") then %>
'***dynamically called image with the Float CSS applied
<img src=<%=(rs_YourRecordSet.Fields.Item("YourImageField").Value)%> class="FloatPic">
<%End If%>
<%
' *** Display the rest of the text
Response.Write MID (strContent ,strStart ,strRemains)
%>