0

I'm trying to show a title of a news as a link

    @using Glass.Mapper.Sc.Web.Mvc
    @model MVC.com.Models.News

   it works:<a href="@Model.Url">@Model.Title</a><br/>
   it dosen't work : @Html.Glass().RenderLink(x => x.Url,new {@class=""} ,true, Model.Title)

Anchor tag works fine but can not generate a link using RenderLink.

Meanwhile, is there any way I can eliminate @Html.Glass() helper from lines? I added Glass.Mapper.Sc.Web.Mvc to file Web.config but still have to wirte @Html.Glass() at the beginning of each command

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
AfshinZavvar
  • 722
  • 1
  • 10
  • 21

2 Answers2

1

You can eliminate @Html.Glass() this way:

@using Glass.Mapper.Sc.Web.Mvc

@RenderLink(Model, x => x.Link, new { @class = "btn" }, true,Model.Title)
Hossein
  • 1,640
  • 2
  • 26
  • 41
0

i think you can do this which should eliminate @Html.Glass()

@inherits GlassView<News>

after that i think you should be able to do this.

@RenderLink(Model, x=>x.Url,new{@class=""},true)
siddhipur
  • 121
  • 1
  • 13