Hi there,
I have a document type including some images fields both direct uploader and image selection. I have successfully showed the image in transformation using the code below.
<tr>
<td>Direct Uploader :</td>
<td><%# IfEmpty(Eval("ArticleImage"), "", GetImage("ArticleImage")) %></td>
</tr>
<tr>
<td>Direct Uploader (resized):</td>
<td><%# IfEmpty(Eval("ArticleImage"), "", GetImage("ArticleImage", 160, 160, 120, Eval("ArticleTitle"))) %></td>
</tr>
<tr>
<td>Image Selection :</td>
<td><%# IfEmpty(GetDocumentUrl("test",""), "", GetImageByUrl(GetDocumentUrl("test","")))%></td>
</tr>
<tr>
<td>Image Selection (resized):</td>
<td><%# IfEmpty(GetDocumentUrl("test",""), "", GetImageByUrl(GetDocumentUrl("test",""), 100, 100, 100, Eval("ArticleTitle")))%></td>
</tr>
Now but i am looking for show document type data in custom webpart. I am using .net repeater to render the data.
However, I got the error message, The name 'IfEmpty' does not exist in the current context, which I realized those functions are only available in CMSAbstractTransformation.
What do I suppose to do to render document type images (both direct uploader and file selection fields) in custom webpart?
The ascx file
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FeatureArticles.ascx.cs"
Inherits="CMSWebParts_RealInsurance_Common_LearningCentre_FeatureArticles" %>
<%@ Import Namespace="CMS.WorkflowEngine" %>
<h2>
FeatureArticle</h2>
<table>
<asp:Repeater runat="server" ID="rprFeatureArticle">
<ItemTemplate>
<tr>
<td>
Direct Uploader :
</td>
<td>
<%# IfEmpty(Eval("ArticleImage"), "", GetImage("ArticleImage")) %>
</td>
</tr>
<tr>
<td>
Direct Uploader (resized):
</td>
<td>
<%# IfEmpty(Eval("ArticleImage"), "", GetImage("ArticleImage", 160, 160, 120, Eval("ArticleTitle"))) %>
</td>
</tr>
<tr>
<td>
Image Selection :
</td>
<td>
<%# IfEmpty(GetDocumentUrl("test",""), "", GetImageByUrl(GetDocumentUrl("test","")))%>
</td>
</tr>
<tr>
<td>
Image Selection (resized):
</td>
<td>
<%# IfEmpty(GetDocumentUrl("test",""), "", GetImageByUrl(GetDocumentUrl("test",""), 100, 100, 100, Eval("ArticleTitle")))%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
Code behind
public partial class CMSWebParts_RealInsurance_Common_LearningCentre_FeatureArticles : CMSAbstractWebPart
{
protected CMSAbstractTransformation Helper;
protected TreeProvider tree;
protected void Page_Load(object sender, EventArgs e)
{
Helper = new CMSAbstractTransformation();
UserInfo ui = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserID);
tree = new TreeProvider(ui);
TreeNode document = CMSContext.CurrentDocument;
DataSet dsLandingFeatureArticles = tree.SelectNodes(CMSContext.CurrentSiteName, document.NodeAliasPath + "/Feature/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "RealInsurance.Article", string.Empty, "NodeOrder", 1);
if (dsLandingFeatureArticles != null)
{
rprFeatureArticle.DataSource = dsLandingFeatureArticles;
rprFeatureArticle.DataBind();
}
}
}