JavaWorld@TW - 利用ASP.NET 2.0快速產生相簿縮圖的方法:
"所需控制項: Dynamic Image, DataList
還要把你的相片全部放在同一個目錄"
<%@ page language="C#" %>
<%@ import namespace="System.IO" %>
<script runat="server">
void Page_Load(object sender, System.EventArgs e)
{
DirectoryInfo directory = new
DirectoryInfo(Path.GetDirectoryName(this.Request.PhysicalPath));
this.Thumbnails.DataSource = directory.GetFiles("*.gif");
this.Thumbnails.DataBind();
}
</script>
<html>
<head runat="server">
<title>DPT Album</title>
</head>
<body>
<form runat="server">
<asp:datalist runat="server" id="Thumbnails" repeatcolumns="3">
<itemtemplate>
<asp:dynamicimage runat="server"
imagefile='<%# Eval("Name") %>'
width="200px">
</asp:dynamicimage>
</itemtemplate>
</asp:datalist>
</form>
</body>
</html>
沒有留言:
張貼留言