Displaying images in specified folder
Quick n easy way to display images in folders
below is how to display all image files in specified folder using datalist.
1. Design
<asp:DataList ID="dtlImg1" runat="server">
<ItemTemplate>
<asp:Image ID="imgThum1" runat="server" Width="90" ImageUrl='<%#FormatURL(DataBinder.Eval(Container.DataItem, "Name"))%>' />
<asp:Label ID="lblFileName" runat="server" Text='<%#Eval("Name") %>'/>
</ItemTemplate>
</asp:DataList>
2. Behind the code
Don't forget to import Imports System.IO
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set directory where you want to browse
Dim strRootPath As String = "/users/mypic/"
Dim myDirInfo As DirectoryInfo
myDirInfo = New DirectoryInfo(Server.MapPath(strRootPath))
dtlImg1.DataSource = myDirInfo.GetFiles()
dtlImg1.DataBind()
End Sub
Tag:
Images Folder IO
By:
syantien
|
1/13/2008 6:04:41 AM
/
1/13/2008 6:08:36 AM
|
* to keep comments safe and clean, we display and keep your ip address.