15

Folks

I'm trying to do something basic here which is have a general link and an image field as editable in experience editor on my view using Glass. my end goal is to have two editable fields which are rendered as:

<a><img></img><a>

I am trying to do something like this but this is not working well

@Html.Glass().Editable(Model, m => m.MyLinkField, new { img = Model.MyImageField })

Anyone know what I'm missing here?

1 Answer 1

26

This should give you what you want:

@using (Html.Glass().BeginRenderLink(Model, m => m.MyLinkField, null, true) {
  @Html.Glass().RenderImage(Model, m => m.MyImageField, null, true)
}
2
  • 1
    that's what I was looking for. thanks Corey!
    – Diego
    Oct 3, 2016 at 19:21
  • 1
    if your view is inheriting from glassView then you can do this:@using (BeginRenderLink(Model, x => x.Link, isEditable: true)) { @RenderImage(Model, x => x.Image, isEditable: true) } Dec 7, 2016 at 11:08

Your Answer

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

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