SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I override the tables rendered around the webparts in the "Rich Content" area?

I have successfully removed the tables around webpartzones and their webparts but can't figure how to remove the tables around Rich Content area webparts.

I am not using the Content Editor WebPart.

The "Rich Content" area I am using is created using the PublishingWebControls:RichHtmlField.

This is the control which has content and webparts.

share|improve this question
up vote 2 down vote accepted

On the same line as with the Francois, there is one excellent article from MVP Waldek Mastykarz explaining not only how-to, but as well implication of changing TABLES into DIVs.

See here

Hope it helps, C:\Marius

share|improve this answer

You can use the ChromeType : none to remove most of the tables but if you want to go further, you'll need one or more control adapter (custom development) that will take care of removing most of the tables generated by the webpart zones and the webparts

For the adapter, you can use the ones from the Accessibility Kit (AKS) or the one (also based on it) adapted by David Schneider

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;

/// WebPartZone Adapter
/// Created by David Schneider
/// Based on AKS

namespace AKSAdapters
  public class AKS_WebPartZone_Adapter : System.Web.UI.Adapters.ControlAdapter
      protected override void Render(HtmlTextWriter writer)
          bool inEditMode = false;
          System.Web.UI.WebControls.WebParts.WebPartZone wpz = Control as System.Web.UI.WebControls.WebParts.WebPartZone;
          if (wpz != null && wpz.Attributes["tableless"] != null)
              SPWebPartManager swpm = (SPWebPartManager)SPWebPartManager.GetCurrentWebPartManager(wpz.Page);
              inEditMode = !swpm.GetDisplayMode().AllowPageDesign;
          if (inEditMode)
              // Render the WebPartZone
              writer.AddAttribute(HtmlTextWriterAttribute.Id, wpz.ID);
              if (!String.IsNullOrEmpty(wpz.CssClass))
                  writer.AddAttribute(HtmlTextWriterAttribute.Class, wpz.CssClass);
              if (wpz.LayoutOrientation == System.Web.UI.WebControls.Orientation.Horizontal)
                  writer.AddAttribute(HtmlTextWriterAttribute.Class, "AspNet-WebPartZone-Horizontal");
              else if (wpz.LayoutOrientation == System.Web.UI.WebControls.Orientation.Vertical)
                  writer.AddAttribute(HtmlTextWriterAttribute.Class, "AspNet-WebPartZone-Vertical");

              // Render the web parts
              if (wpz.WebParts.Count > 0)
                  WebPartCollection wpColl = new WebPartCollection(wpz.WebParts);

                  foreach (System.Web.UI.WebControls.WebParts.WebPart wp in wpColl)
                      writer.AddAttribute(HtmlTextWriterAttribute.Class, "AspNet-WebPart");

                      writer.RenderEndTag(); // Div
              writer.RenderEndTag(); // Div

              // If we are editing the page --> render the web part as usual.

and to isolate it to the content editor web part, you can bind a control adapter to just that webpart

    <browser refID="Default">
adapterType="ProjectName.SharePoint.Adapters.ContentEditorWebPartAdapter" />

And override the render but I'm not sure that the wrapping table mentioned is generated at the render process.


share|improve this answer
Yes, the exact control adapter is what I am looking for. – iambriansreed Mar 23 '12 at 13:36
I have updated my reply to point to the adapter that I based my development on. Edit : saw that you updated your question as well so you already know that kind of stuff. What about removing the final ones injected by the CEWP through a little bit of JQuery ? I never noticed the CEWP is wrapping its content in another table but I'm relying on publishingHtml field in my content type and try to discard the CEWP as much as possible – Francois Verbeeck Mar 23 '12 at 14:03
I am not using the CEWP. When I refer to the "Rich Content" area I am using the PublishingWebControls:RichHtmlField. This is the control which has normal content and some webparts. – iambriansreed Mar 23 '12 at 14:18
I think Waldek wrote something about it. I would anyway try the jquery road since it's quite easy to remove wrapping elements if you know where to look at (if and your adapter is already wrapping or identifying your webparts with classes or id, it should be easy). – Francois Verbeeck Mar 23 '12 at 14:30
I have to to this server side. I hate that jump in formatting. – iambriansreed Mar 23 '12 at 14:38

If your table has some unique class or id you can consider using jQuery to dynamically remove any of the DOM element using simple jQuery script

Consider doing it through jQuery

share|improve this answer
I want to do this server side without WPS. – iambriansreed Mar 29 '12 at 19:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.