我有一个带有图片库的网站。我想动态地将图片添加到图库中。我有这个代码:
string[] files = Directory.GetFiles(Server.MapPath(@"images\gallery\projects"));
string temp = files[0];
for (int i = 1; i < files.Length; i++)
{
HyperLink hp = new HyperLink();
hp.ImageUrl = "images/gallery/projects/" + Path.GetFileName(files[i]);
hp.NavigateUrl = "images/gallery/projects/" + Path.GetFileName(temp);
Panel1.Controls.Add(hp);
temp = files[i];
}
这会用图片迭代文件夹并生成链接标签,但这不是我需要的。我正在尝试生成此标签:
<a href="images/gallery/picture_fullsize.jpg"
title="Caption for picture goes here">
<img src="images/gallery/picture_thumbnail.jpg"/>
</a>
任何指针或解决方案将不胜感激。