我知道这个帖子现在已经很老了,但对任何人都可能是有帮助的。我有同样的问题,并使用这种编码。
配置文件
<add key="WebResources" value="~/Assets/WebResources/" />
<add key="ImageRoot" value="Images\Web" />
<add key="ProfileImages" value="Images\Profile" />
Asp.Net Datalist中
<asp:DataList ID="dlPrivateAlbum" runat="server" OnItemCommand="dlPublicAlbum_ItemCommand" RepeatDirection="Horizontal" RepeatLayout="Flow">
<ItemTemplate>
<div class="boxgrid captionfull">
<asp:Literal ID="lit_ImagePath" runat="server" Text='<%# Eval("URL") %>' Visible="false" />
<asp:HyperLink runat="server" Target="_blank" ToolTip='<%#Eval("Description") %>'
ImageUrl='<%# ConfigurationManager.AppSettings["WebResources"] + ConfigurationManager.AppSettings["ProfileImages"] + @"\thumbs\" + Eval("URL") %>'
NavigateUrl='<%# ConfigurationManager.AppSettings["WebResources"] + ConfigurationManager.AppSettings["ProfileImages"] + @"\" + Eval("URL") %>' />
<div class="cover boxcaption">
<asp:LinkButton ID="lnkbtn_Edit" runat="server" CommandArgument='<%# Eval("ID") %>' CommandName="edit" CssClass="captionlink" Text='<%#Eval("Title") %>' />
</div>
</div>
</ItemTemplate>
CSS:
.boxcaption{float:left;position:absolute;background:#000;height:70px;width:100%;opacity:.8;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80);-MS-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"}
.captionfull .boxcaption{top:230px;left:0}
.caption .boxcaption{top:190px;left:0}
.captionlink:link, .captionlink:visited {color: #E2E2E2;text-decoration: none;}
.captionlink:hover { text-decoration: underline; }
.captionlink:active {color: #F5F5F5;}
背后代码:
private void load(Guid userID)
{
try
{
loadOptions();
DbContext = new Entities();
user = DbContext.UserProfiles.FirstOrDefault(d => d.UserID == userID);
List<Album> albums = DbContext.Albums.Where(d => d.UserID == userID).ToList();
if (albums != null)
{
dlPublicAlbum.DataSource = albums.FirstOrDefault(d => d.Type == "public").Images;
dlPublicAlbum.DataBind();
}
}
catch (Exception ex)
{
Msg.ShowAlert(this.Parent.Page, Msg.GeneralError_Title + " " + ex.GetType().Name, ex.Message, MsgType.Error);
}
}
感谢重播, 但我如何将这个新创建的缩略图图像绑定在中继器控制中。是否有任何代码来实现 – happysmile 2009-11-13 06:13:17
中继器控件的内部添加一个图像控件,并将URL设置为指向Handler.ashx控件。您需要某种唯一标识符来标识您希望Handler制作缩略图的图像。 – sgriffinusa 2009-11-13 08:22:59
嘿我试过所有的组合没有任何工作,如果你可以写代码将是伟大的亚尔 – happysmile 2009-11-14 14:47:23