Display an image using asp help

  • Thread starter Thread starter Paul C
  • Start date Start date
P

Paul C

Hi Guys hope all is well
How do I store an image in a dim and then display it on the page somnething
like

<%
Dim sImage
sImage = image path
%>

<% Display the image here %>

Thanks
Paul M
 
<%
Dim sImage, sAlt
sImage = "/images/imagename.jpg"
sAlt ="Alternative image text"
%>


<img src="<%=sImage%>" alt="<%=sAlt%>">

You should also add width and height attributes for the image, either as
variables similar to above, or fixed for all images (if all images are
the same size or only *slightly* larger).
 
The page will render as though the image was not there, then readjusts
when the image loads. This is, perhaps, a little disconcerting
(especially with a large image downloading on dial-up) and is slower
than when dimensions are present. With dimensions present the browser
knows how much space to allocate for the image and renders the page
accordingly, first time.
 
If you wanted the size attributes then you could just add to Ron's script.
Ex:

<%
Dim sImage, sAlt, sWidth, sHeight
sImage = "/images/imagename.jpg"
sAlt ="Alternative image text"\
sWidth = "600"
sHeight = "200"
%>


<img src="<%=sImage%>" alt="<%=sAlt%>" width="<%=sWidth%>" height
="<%=sHeight%>">

If you have a lot of images you might want to consider storing all this
information in a database and then pulling it from the database along with
all it's attributes
 
Thanks Guys
Paul M
David Berry said:
If you wanted the size attributes then you could just add to Ron's script.
Ex:

<%
Dim sImage, sAlt, sWidth, sHeight
sImage = "/images/imagename.jpg"
sAlt ="Alternative image text"\
sWidth = "600"
sHeight = "200"
%>


<img src="<%=sImage%>" alt="<%=sAlt%>" width="<%=sWidth%>" height
="<%=sHeight%>">

If you have a lot of images you might want to consider storing all this
information in a database and then pulling it from the database along with
all it's attributes
 
Back
Top