我知道這個帖子現在已經很老了,但對任何人都可能是有幫助的。我有同樣的問題,並使用這種編碼。
配置文件
<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