2

I'm working on displaying a Richtext in MVC Sitecore View.

Below is my code

<div class="modal-body">
@Html.Sitecore().Field("{ACBE8753-2970-****-A022-4C4******4AA}")
</div>

When I click on Modal pop up link, I see its empty (below is screenshot). Any suggestions would be much appreciated.

When I put simple HTML content. Its working. But, Rich text or simple text is not working in Modal Pop up:

enter image description here

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
EKD
  • 73
  • 7

3 Answers3

0

@Html.Sitecore().Field() method does NOT accept field ID (guid) as parameter.

Options are:

public virtual HtmlString Field(string fieldName)
public virtual HtmlString Field(string fieldName, object parameters)
public virtual HtmlString Field(string fieldName, Item item)
public virtual HtmlString Field(string fieldName, Item item, object parameters)

EDIT:

Above are method definitions. Use e.g.:

<div class="modal-body">
@Html.Sitecore().Field("Modal Content")
</div>

where Modal Content is replaced with whatever your field name (with guid {ACBE8753-2970-****-A022-4C4******4AA}) is.

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
  • Hi Merek, So, here we are not using any server side programming. We have to stick to client side options. – EKD May 12 '17 at 09:11
0

You can get item like this:

 var item = Sitecore.Context.Database.GetItem("your item ID or your path ID")

Display your richtext field:

 @Html.Sitecore().Field("name of your richtext field", item)
ThinhLe
  • 409
  • 1
  • 3
  • 12
0

It was because of wrong HTML references. Nothing wrong with Sitecore.

EKD
  • 73
  • 7