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?

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)
}
| improve this answer | |
  • 1
    that's what I was looking for. thanks Corey! – Diego Oct 3 '16 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) } – Dheeraj Palagiri Dec 7 '16 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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