Forums
This topic is locked
show the FileName
28 Jan 2004 17:08:21 D J posted:
Hello,I've got this script bu now i want to add the filename under the image i tried a lot but it won't work. It does show the pictures but it doen't show the pictures names!! Is there anyone who could help or give me a usefull link
Thanks!! David
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Const Plaatjes as String = "/david_10/"
Const maxH as Integer = 100
Const maxW as Integer = 100
Dim pics as ArrayList = new ArrayList()
Dim s as String, html as String
Dim imgH, imgW as Integer
For Each s in Directory.GetFiles(Server.MapPath(Plaatjes), "*.gif"
Dim currentImage as System.drawing.Image = System.Drawing.Image.FromFile(s)
imgH = currentImage.Height
imgW = currentImage.Width
If imgW > maxW OR imgH > maxH then
Dim deltaW as Integer = imgW - maxW
Dim deltaH as Integer = imgH - maxH
Dim scaleFactor as Double
If deltaH > deltaW then
scaleFactor = maxH / imgH
else
scaleFactor = maxW / imgW
End If
imgW *= scaleFactor
imgH *= scaleFactor
end If
html = "<a href=""" & Plaatjes & Path.GetFileName(s) & """>" & _
"<img src=""" & Plaatjes & Path.GetFileName(s) & """" & _
"height=""" & imgH & """ width=""" & imgW & """>" & _
"</a>"
pics.Add(html)
Next
dlPictures.DataSource = pics
dlPictures.DataBind()
End Sub
</script>
Replies
Replied 30 Jan 2004 16:46:08
30 Jan 2004 16:46:08 Lee Diggins replied:
Like this maybe?
html = "<a href=""" & Plaatjes & Path.GetFileName(s) & """>" & _
"<img src=""" & Plaatjes & Path.GetFileName(s) & """" & _
"height=""" & imgH & """ width=""" & imgW & """>" Path.GetFileName(s) & _
"</a>"
Digga
Sharing Knowledge Saves Valuable Time!!!
html = "<a href=""" & Plaatjes & Path.GetFileName(s) & """>" & _
"<img src=""" & Plaatjes & Path.GetFileName(s) & """" & _
"height=""" & imgH & """ width=""" & imgW & """>" Path.GetFileName(s) & _
"</a>"
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 30 Jan 2004 20:16:26
30 Jan 2004 20:16:26 D J replied:
Thank I'll give it a try!!