episerver:property renders additional div tag?

Member since: 2006
 

Hi,

I have demo installation of EPiServer (demo site) in version 5.1.422.122. In markup file I have this code:

<div id="MainBodyArea">
    <EPiServer:Property PropertyName="MainBody" EnableViewState="false" runat="server" />
</div>

MainBody property has this value (html):

<H1>Welcome</H1>
<P>EPiServer is an easy and&nbsp;adaptable platform for communication and collaboration on the web, fully integrated in the organizations activities and business processes. With EPiServer CMS 5 we have laid the foundation to realize bigger, funnier, more&nbsp;powerful and&nbsp;intense web sites.</P>

But this is rendered as:

<div id="MainBodyArea">
  <div>
    <h1>Welcome</h1>
    <p>EPiServer is an easy and adaptable platform for communication and collaboration on the web, fully integrated in the organizations activities and business processes. With EPiServer CMS 5 we have laid the foundation to realize bigger, funnier, more powerful and intense web sites.</p>
   </div>
</div> 

Please note additional div elements inside div with id MainBodyArea. In admin mode option Use DIV in Editor instead of P is NOT selected.

 Is there any way to stop episerver:property to render this additional div tag?

-- 

Best regards,

Dominik

 

 

#19882 May 12, 2008 15:00
  • Member since: 2008
     

    Same problem...

    I don't have any solutions right now but still looking ahead.

    #19888 May 13, 2008 14:56
  • Member since: 2008
     

    Well... Only one working solution may be used here - you must place <EPiServer:Property> and surrounding text inside a <table>...</table>. Property - inside it's own <td>...</td>. Only then you won't take the full weight of this bothering <div>...</div> tags.

    I hope EPiServer's devlopping team will guive us something to correct this issue in the future... 

    #19935 May 15, 2008 9:58
  •  

    This is quite an uneducated guess, but:

     The property you are using is an Xhtml-string (>255), that is located in EPiServer.SpecializedProperties.PropertyXhtmlString which in turn inherits from EPiServer.Core.PropertyLongString. If we take a look at PropertyLongString we see that the control used to render a PropertyLongString is a EPiServer.Web.PropertyControls.PropertyLongStringControl.

     Again, if we look at PropertyLongStringControl we see that it's CreateDefaultControls method (which is used to create the default representation of the control) is something like:

    Panel target = new Panel(); Literal child = new Literal(); child.Text = this.toWebString(); target.Controls.Add(child); this.Controls.Add(target);

    So, it renders a Panel with a Literal inside of it, a Literal does not render any specific markup by itself, but the Panel will render a <div> tag.

    So, an option to get around this would be to read the articles by Steve and Mari which describe how to change this behaviour:

    Article by Steve: Taking Control of Property Rendering

    Article by Mari (followup): Replacing Property Rendering Using Adapters

    Hope this is helpfull, and as a disclaimer, I have not tested this myself, I am only guessing.

    #19938 Edited, May 15, 2008 15:50
  • Member since: 2005
     

    Hi,

    Has anyone manage to override PropertyLongStringControl so the extra <div> tag will be removed? I tried to follow the articles from Steve and Mari but it doesn't seem to work.

    I managed to get PropertyStringControl to work but not PropertyLongStringControl. Any have some working code to share?

    Best Regards
    Anders

    #21025 Jun 19, 2008 9:30
  • Member since: 2003
     

    As Aanund wrote in his post, this can be solved by reading through the blog postings by Steve and me. I did a quick test, and got it up and running. I created a PageAdapter (code sample below) and mapped the new adapter using the .browser file. Note that you should add check to see if property has value, and if any css class is provided.

    using EPiServer.Web.PropertyControls.Adapters; namespace EPiServer.Templates { public class LongStringAdapter : PropertyDataControlAdapter { public override void CreateDefaultControls() { //base.CreateDefaultControls(); //Panel target = new Panel(); Literal child = new Literal(); child.Text = this.ToWebString(); //target.Controls.Add(child); //this.Controls.Add(target); this.Control.Controls.Add(child); } } }

     In .browser:

    <adapter controlType="EPiServer.Web.PropertyControls.PropertyLongStringControl" adapterType="EPiServer.Templates.LongStringAdapter" />

     /Mari

    #21206 Jun 20, 2008 13:10
  • Member since: 2007
     

    Its not a fix but rahter a workaround

     http://www.from-rizo.se/2009/02/27/workaround-for-episerverproperty-renders-an-extra-div/ 

     Hope this helps anyone :)

    #28252 Feb 27, 2009 16:12
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
Please login to post a reply