Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm using Umbraco 7
I was trying to only show the item.content and item.file only if it has value. But if user didn't upload/input any text it shouldn't be showing.
I've tried using this code but it still shows the content and download button despite the item has no file/content to show
<!-- Check first if content or file exists --> @if(item.content!=null){ <a href="#@item.Id" data-toggle="collapse">Lihat selengkapnya »</a> <div id="@item.Id" class="collapse"> <p>@item.content</p> <!-- Check if file exists --> @if(item.file!=null){ <p> <a href="@item.file" class="btn btn-warning">Download</a> </p> } }
Is there any other way to check if a property is exist but has no value/empty?
Thanks!
Hi rendervouz,
You could use:
@if(item.HasValue("file")){ <p> <a href="@item.file" class="btn btn-warning">Download</a> </p> }
Then if the field has a value then it will be outputted.
Hope this helps,
/Dennis
This solves the problem. Many thanks!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Check if a property is exist but empty/has no value
I'm using Umbraco 7
I was trying to only show the item.content and item.file only if it has value. But if user didn't upload/input any text it shouldn't be showing.
I've tried using this code but it still shows the content and download button despite the item has no file/content to show
Is there any other way to check if a property is exist but has no value/empty?
Thanks!
Hi rendervouz,
You could use:
Then if the field has a value then it will be outputted.
Hope this helps,
/Dennis
This solves the problem. Many thanks!
is working on a reply...