当前位置: 动力学知识库 > 问答 > 编程问答 >

sitecore - sc:Image outputting raw field value

问题描述:

I'm having trouble where my sc:Image tag is outputting the raw XML field value instead of the <img> tag I expect. It's only happening on this one page, but the Repeater with ItemType is a pattern I've done on many other pages without issue.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="MyProject.Web.TestPage" %>

<%@ Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<table>

<asp:Repeater runat="server" ID="rptSublayouts" ItemType="Sitecore.Data.Items.Item">

<ItemTemplate>

<tr>

<td>

<sc:Image runat="server" Field="__Thumbnail" Item="<%# Item %>"

CssClass="thumbnail-image" MaxWidth="250" MaxHeight="250" />

</td>

</tr>

</ItemTemplate>

</asp:Repeater>

</table>

</form>

</body>

</html>

The output looks like this:

<tr>

<td>

<image mediapath="/MyImages/three-column-body"

mediaid="{343C5D5E-94C8-4D9A-B8E0-C65F89C0C155}"

src="~/media/343c5d5e94c84d9ab8e0c65f89c0c155.ashx?20140523T0953399715" />

</td>

</tr>

Has anyone seen this behavior? I suspect it is something small that my eyes just aren't seeing this morning.

网友答案:

<sc:image> works only with the field that use Image field type.

__Thumbnail field does not use Image field type. It uses Thumbnail.

That's why the output is just a raw XML.

分享给朋友:
您可能感兴趣的文章:
随机阅读: