What does the source look like in TinyMCE while in edit mode? It should look something like this where the block is inserted:
The important part here is the data-classid and data-contentlink attribute. The block cannot be found if those are missing.
The rendering of the block does not work either if you have the focus inside TinyMCE.
And by the way, how are you rendering the xhtml property in the template/view? And which base class do you inherit from in your block renderer?
The source inside the timy mce editor looks like this:
I render the xhtml property like this:
And I inherit from the BlockControlBase
This is what causing the problem:
EPiServer.Core.PropertyDataCollection.GetHandler = new GetPropertyDelegate(EPiServer.EmailPropertyGetHandler.EmailPropertyHandler);
The EmailPropertyHandler converts mailto inks to links to contact forms. Unfortunatly it also strips the data-contentlink and the data-classid from the:
Is it possible that the GetPropertyDelegate cant hadle the data-tags?
No, its a custom written method that converts email andresses in mainbody into adresses to contact form.
public static PropertyData EmailPropertyHandler(string name, PropertyDataCollection properties)
{
if (name.Equals("MainBody")
{
PropertyData property = properties.Get(name);
//////[Code]/////
Already on the last line there the data-classid and the data-contentlink attributes for the block is gone.
I think it is the same when I use the DefaultPropertyHandler (from EPiServer.Core.PropertyGetHandler).
Hi, we have the same problem when trying to modify the mainbody on the publishing event.
public virtual void OnPublishing(PageEventArgs ea)
{
var mainBody = ea.Page.Property["MainBody"].Value;
// Here is data-classid and data-contentlink gone
We are using Slimresponse and we modify the image tags in the MainBody to achieve responsive images.
This seems to break the block rendering in Xhtml.
If you cast the property to a XhtmlString and then use the method .ToInternalString() it seems like you get what you are looking for.
Edit: You may need to cast the property to an XhtmlStringProperty and then the value to a XhtmlString.
I have a pretty plain block, with image, link and text. I have tried to drag n drop it to a xhtml field, but all it renders are the block name.
The block works fine in a content area.