You may try with this code
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim iFileCnt As Integer = 0
Dim dirInfo As New System.IO.DirectoryInfo(Server.MapPath("~/images/theme/"))
Dim listfiles As FileInfo() = dirInfo.GetFiles("*.*")
If listfiles.Length > 0 Then
For Each file As FileInfo In listfiles
' CHECK THE TYPE OF FILE.
If Trim(listfiles(iFileCnt).Extension) = ".jpg" Or _
Trim(listfiles(iFileCnt).Extension) = ".jpeg" Or _
Trim(listfiles(iFileCnt).Extension) = ".png" Or _
Trim(listfiles(iFileCnt).Extension) = ".bmp" Or _
Trim(listfiles(iFileCnt).Extension) = ".gif" Then
Dim img As New HtmlImage
Dim newDiv As New HtmlGenericControl("div")
Dim textDiv As New HtmlGenericControl("div")
' ADD IMAGE.
img.Src = "~/images/theme/" & listfiles(iFileCnt).Name
img.Width = "130"
img.Height = "130"
newDiv.Attributes.Add("style", "float:left;padding:5px 3px;
margin:20px 3px;height:auto;overflow:hidden;")
newDiv.Controls.Add(img)
' ADD A TEXT.
textDiv.Attributes.Add("style", "display:block;font:13px Arial;padding:10px 0;width:" & _
img.Width & "px;color:#666;text-align:center;cursor:pointer;")
textDiv.InnerText = "Various Catgories - Binding, Product Specification, Author (Price Tag)"
newDiv.Controls.Add(textDiv)
divGallary.Controls.Add(newDiv)
End If
iFileCnt = iFileCnt + 1
Next
End If
End Sub
End Class
DOT NET
Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator