Copied to clipboard

Flag this post as spam?

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


  • jtrip 13 posts 103 karma points
    Jul 15, 2016 @ 14:59
    jtrip
    0

    Using the Model of an updated Data Type in a parial view

    Hello,

    I am working on a staging site that is running, and want to update the way a partial view is using the model of a Data Type.

    For instance the (archetype) data type previously allowed the user to select one image and I want to allow the user to select two images which then should be accessible from a new or updated partial view.

    I added a second media picker property to the data type and that is visible to the backoffice user. However when I write a block in the partial view that tries to access the data the user selected the site will produce a 500 error whenever that partial is loaded.

    Here I added a media picker property named sImage to the DataType that already had a media picker named Image. And tried to access it in a partial like so:

        @if (Model.Image.IsSet())
        {
            <div class="feature-img-right">
                <img src="@Model.Image.Url" alt="@Model.Image.Alt" />
            </div>
        }
    
        @if (Model.sImage.IsSet())
        {
            <div class="new-img">
                <img src="@Model.sImage.Url" alt="@Model.sImage.Alt" />
            </div>
        }
    

    I am guessing this is because changing the Data Type properties etc doesn't actually change the model? Is there some way to update the model or a trick to access new properties of a Data Type without updating the model? I might be misunderstanding the relationship between Data Types and the models.

    Thanks for any help!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Oct 11, 2016 @ 16:17
    Alex Skrypnyk
    0

    Hi jtrip,

    What error exactly do you have?

    Can you share text of exception?

    Maybe Model.sImage is null?

    What is IsSet() method?

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft