Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Portals 7.0.0021: ChildNavigation.ascx

(0) ShareShare
ReportReport
Posted on by 3,914

Hello:

Running Portals 7.0.0021 on CRM 2016. Am attempting to modify the code Adx created for rendering the child pages on a web page. I am trying to make it a tiled view with thumbnails and am having a problem with the image part.

In the Web Page form for each of my web pages, the Image URL field is filled in with a path to an image loaded in Web Files (example: /displayproducts.png).

Here is my ASP.net code:

                       <% foreach (var node in Children) { %>
                           <div class="col-md-4">
                        <div><a href="<%: node.Url %>"><img src='<%: GetImage(node) %>' /></a>
                        <div><h4><%: node.Title %></h4></div>
                        <div style="height:125px"><h5><%= GetDescription(node) %></h5></div>
                        <div style="margin-bottom:10px"><a href="<%: node.Url %>" class="btn btn-primary" role="button">Learn More  <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></a></div></div>
                             </div>
                    <% } %>

And here is the function I wrote in the code behind:

        protected object GetImage(SiteMapNode node)
        {
            if (node == null)
            {
                return null;
            }

            var entityNode = node as CrmSiteMapNode;

            if (entityNode == null || entityNode.Entity == null)
            {
                return "displayproducts.png";
            }

            var entity = XrmContext.MergeClone(entityNode.Entity);

            switch (entityNode.Entity.LogicalName)
            {
                case "adx_communityforum":
                    return Html.TextAttribute(XrmContext, entity, "adx_description");
                case "adx_shortcut":
                    return Html.HtmlAttribute(XrmContext, entity, "adx_description");
                case "adx_blog":
                case "adx_event":
                case "adx_webfile":
                case "adx_webpage":
                    return Html.HtmlAttribute(XrmContext, entity, "adx_imageurl");
                default:
                    return "displayproducts.png";
            }
        }

None of the images appear though, just the X trying to load it.

When I view the source of the page in Internet Explorer, it is pulling the data I have in the field in CRM, but there is a bunch of other code getting added around it:

<div><a href="/display-products/oled/"><img src='<div class="xrm-editable-html xrm-attribute"><div class="xrm-attribute-value">/displayproducts.png</div></div>' /></a>

Is there a way to make this work so I can display the image too?

Thank you.

-Joe

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans