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
here is my code that i write in umbraco templatebut its return error plz tell me where is i'm wrong
<% if ((umbraco.library.GetItem('pageheaderLink') == '') { <umbraco:Item field="pageheader" runat="server" /><% } else { %><a href='<umbraco:Item field="pageheaderLink" runat="server" />'><umbraco:Item field="pageheader" runat="server" /></a><% } %>
There is a one ( too many in the if-statement.
Dave
budy plz guide for the correct format for above code
Hi Shine,
It would be like this:
<% if ((umbraco.library.GetItem("pageheaderLink") == "")) { %> <umbraco:Item field="pageheader" runat="server" /> <% } else { %> <a href='<umbraco:Item field="pageheaderLink" runat="server" />'><umbraco:Item field="pageheader" runat="server" /></a> <% } %>
However, I would recommend that you use a inline Razor macro instead, this would be like this:
<umbraco:Macro runat="server" language="cshtml"> @{ if (!Model.HasValue("pageheaderLink")){ <span>@Model.pageheader</span> } else { <a href="@Model.pageheaderLink">@Model.pageheader</a> } } </umbraco:Macro>
Thanks,
Jeavon
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
how we can write condition in template
here is my code that i write in umbraco templatebut its return error plz tell me where is i'm wrong
<% if ((umbraco.library.GetItem('pageheaderLink') == '') {
<umbraco:Item field="pageheader" runat="server" />
<% } else { %>
<a href='<umbraco:Item field="pageheaderLink" runat="server" />'><umbraco:Item field="pageheader" runat="server" /></a>
<% } %>
There is a one ( too many in the if-statement.
Dave
budy plz guide for the correct format for above code
Hi Shine,
It would be like this:
However, I would recommend that you use a inline Razor macro instead, this would be like this:
Thanks,
Jeavon
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.