- ·上一篇文章:ASP.NET中利用Crystal Report创建图表
- ·下一篇文章:将Word文档转化为HTML格式的文档
保存美丽记忆 用ASP.NET创建网络相册
Sub Page_Load(sender as Object, e as EventArgs)
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
Dim images() as FileInfo = FilterForImages(dirInfo.GetFiles())
Dim imgIndex as Integer = 0
If Not Request.QueryString("N") is Nothing AndAlso IsNumeric(Request.QueryString("N")) then
imgIndex = CInt(Request.QueryString("N"))
End If
currentImgTitle.Text = "You are Viewing: " & _
Path.GetFileNameWithoutExtension(images(imgIndex).Name) & _
" (" & imgIndex + 1 & " of " & images.Length & ")"
currentImg.ImageUrl = Path.GetFileName(images(imgIndex).Name)
If imgIndex > 0 then
lnkPrev.NavigateUrl = "Default.aspx?N=" & imgIndex - 1
End If
If imgIndex < images.Length - 1 then
lnkNext.NavigateUrl = "Default.aspx?N=" & imgIndex + 1
End If
dlIndex.DataSource = images
dlIndex.DataBind()
End Sub
Function FilterForImages(images() as FileInfo) as FileInfo()
Dim newImages as New ArrayList(images.Length)
Dim i as Integer
For i = 0 to images.Length - 1
If Path.GetExtension(images(i).Name) = ".jpg" OrElse _
Path.GetExtension(images(i).Name) = ".jpeg" OrElse _
Path.GetExtension(images(i).Name) = ".png" OrElse _
Path.GetExtension(images(i).Name) = ".gif" then
newImages.Add(images(i))
End If
Next
Return CType(newImages.ToArray(GetType(FileInfo)), FileInfo())
End Function
Sub dlIndex_ItemDataBound(sender as Object, e as DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem then
Dim hl as HyperLink = CType(e.Item.FindControl("lnkPic"), HyperLink)
hl.Text = Path.GetFileNameWithoutExtension(DataBinder.Eval(e.Item.DataItem, "Name").ToString()) & _
" (" & Int(DataBinder.Eval(e.Item.DataItem, "Length") / 1000) & " KB)"
hl.NavigateUrl = "Default.aspx?N=" & e.Item.ItemIndex
End If
End Sub
</script>
<HTML>
<HEAD>
<STYLE TYPE="text/css">
body { font-family:Verdana;font-size: medium;}
.ImageTitle { font-weight:bold; font-size:large;}
.index {font-size: sma

