Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

epi-property tag helper not working

Vote:
 

Hello,

Can someone clarify what is wrong here. I have a model with two properties AddressLabel which is a string and Ilist<AddressBlock>. 

On the view I have as following

 <span epi-property="AddressLabel" />

@foreach(var addr in Model.AdditionalAddress)

{

     <span epi-property="@addr.StreetAddress" />

}

I can debug this and values for StreetAddress is coming through, however in the rendered view, I can see the AddressLabel but the Street Address is rendered blank. Am I missing anything with epi-property tag helper

#336612
Feb 10, 2025 16:04
Vote:
 

Please try this 

<span epi-property="AddressLabel"></span>

@if (Model.AdditionalAddress != null)
{
    @foreach (var addr in Model.AdditionalAddress)
    {
        <span>@addr.StreetAddress</span>
    }
}

epi-property should only be used with model properties directly, not within a loop or on dynamic values.

To output collection items, just use @addr.StreetAddress instead of epi-property.

#336645
Feb 11, 2025 11:24
Dileep D - Feb 12, 2025 14:17
Thanks for the update. I used Html.PropertyFor which worked for those properties. Was just curious on why epi-property wouldn't work and if it was something at my end.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.