Show Page Editor Message

Hi All,

In one of our project we have full page editor support. Most controls are Datasource based. So the requirement is that when there is no datasource assigned to any rendering, then we need to show a message so that anyone can identify that there is a control and they can assign datasource there. We are coding in MVC.

So for that I have created a simple Model “PageEditorModel”

namespace abc.Models
public class PageEditorModel
public string Message { get; set; }

Also created Partial View with the name “PageEditorMessage”, in which there is only message to show.

@inherits ModelView


Now its time for Sitecore. I have created Dictionary for page editor message. You can see below.


Now let’s take an example of a Rendering that is Datasource based control. In which I am checking if Datasource is null then showing PageEditor Message.

@inherits ModelView

@if (Sitecore.Mvc.Presentation.RenderingContext.Current.Rendering.DataSource.IsNullOrEmpty() && Sitecore.Context.PageMode.IsExperienceEditor)
@Html.Partial(“/renderingPath/PageEditorMessage.cshtml”, new PageEditorModel() { Message = RenderDictionaryValue(KSCVCPII.Domain.Common.DictionaryKeys.AssociateContentMessage).ToHtmlString() })
// Code here..

To render the dictionary value I have created a method. You can see below –

public IHtmlString RenderDictionaryValue(string value)
return new MvcHtmlString(HttpUtility.HtmlDecode(Sitecore.Globalization.Translate.Text(value)));


So you can see the message here in the image and you can select this rendering now and can give datasource with page editor as well.

Yes that’s all.

Happy Coding 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s