1

Here is my code:

<div class="btn-lg">@Html.Sitecore().Field("Feature Link", Model.Item, new { text = @Html.Sitecore().Field("Feature Link Button Text", Model.Item)})</div>  

here is what it is rendering:

<a  Apply ></a>

1 Answer 1

3

Original problem was data related. Answer below explains how to achieve same thing in cleaner (and possibly safer) way

I guess Sitecore cannot handle nested @Html.Sitecore().Field() code.

Try this code:

<div class="btn-lg">
    @Html.Sitecore().BeginField("Feature Link", Model.Item)
    @Html.Sitecore().Field("Feature Link Button Text", Model.Item)
    @Html.Sitecore().EndField()
</div>
3
  • I tried that, and I thank you for your help, but now I don't get a link at all, but the text. Jun 7, 2017 at 18:40
  • Actually the fault was my own, I did not specify a link, now that I have I believe this is working.thank you Jun 7, 2017 at 18:47
  • 1
    Can we close this question, or update the answer to reflect that the problem was data related and not code related. If you had a link, the original code would probably have worked OK. Although Marek's is safer.
    – Richard Seal
    Jun 8, 2017 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.