Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bhagirath pancholi 19 posts 88 karma points
    Feb 26, 2018 @ 09:16
    bhagirath pancholi
    0

    I want to render archetype property content value in partial view without using controller and model

    I want to render archetype property content value in partial view without using mvc(controller and model) . i get this error "foreach statement cannot operate on variables of type object because object does not contain public defination for 'getenumerator"' could you please help me with this. or give me sample code. see code in image. or suggest me to achieve my requirement. enter image description here

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Feb 26, 2018 @ 09:31
    Alex Skrypnyk
    0

    Hi Bhagirath

    Try this code:

    var icons = Model.Content.GetPropertyValue<ArchetypeModel>("writeDetailsForIconsText");
    
    foreach(var icon in icons.Fieldsets.Where(x => !x.Disabled))
    

    /Alex

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Mar 09, 2018 @ 09:09
    Alex Skrypnyk
    0

    Hi Bhagirath

    Did you solve the issue? Can you share with our community?

    /Alex

  • bhagirath pancholi 19 posts 88 karma points
    Mar 10, 2018 @ 13:21
    bhagirath pancholi
    1

    hi Alex Skrypnyk, I write partial view without help of controller. see below code, hope this help

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    

    @using ContentModels = Umbraco.Web.PublishedContentModels; @using Umbraco.Core.Models.PublishedContent; @using Umbraco.Web.Models;

    @{
    var icons = Model.Content.GetPropertyValue("writeDetailsForIconsText");
    //string imgurl = Model.Content.GetPropertyValue<IPublishedContent>("iconInIconTextArchetype").Url;
    

    }

    <section class="dms-services">
    <div class="container">
        <div class="row">
            @foreach (var icon in (dynamic)(icons))
            {
                var mediaItem = icon.GetValue<IPublishedContent>("iconInIconTextArchetype");
                string imageUrl = string.Empty;
                if (mediaItem != null)
                {
                    imageUrl = mediaItem.Url;
                }
                //string image = icon.GetValue<IPublishedContent>("iconInIconTextArchetype").;
                var title = icon.GetValue<String>("titleInIconTextArchetype");
                var description = icon.GetValue<String>("descriptionInIconTextArchetype");
                var wantbtn = icon.GetValue<bool>("wantButton");
                var btntext = icon.GetValue<String>("buttonTextInIconTextArchetype");
                var rblink = icon.GetValue<RelatedLink>("buttonUrlInIconTextArchetype");
                var btnurl = rblink != null ? rblink.FirstOrDefault().Link : string.Empty;
    
                <div class="col-12 col-xl-6 col-lg-6 col-md-6 col-sm-12">
                    <div class="service-image-wrap">
                        <img src="@imageUrl">
                    </div>
    
                    <h4>@title</h4>
                    @Html.Raw(description)
                @if(wantbtn == true)
                {
                    <a href="@btnurl" class="read-more">@btntext<i class="fa fa-arrow-circle-right" aria-hidden="true"></i></a>
                }
                </div>
            }
    
        </div>
    </div>
    

    enter image description here

    @Html.Partial("RenderSection/_IconsPlusText") use this in main page to render this control.

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Mar 10, 2018 @ 19:22
    Alex Skrypnyk
    0

    Hi Bhagirath

    Thank you very much for sharing!

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft