How to Properly Remove a Web Part from a Web Part Page

A common observation I make when working with clients is how web parts are removed from a page, and more importantly, how they are improperly removed from the page.

First, I’ll explain the improper ways, then get into why these are bad practices, and then how to properly remove web parts from a web part page.

Improper Method #1 – “Close”
There are usually two ways I see this take place, the first being the Close option off of the Web Part menu, available when the page is not in edit mode (and the user has proper permissions of course!), as well as when the page is in edit mode.

Improper Method #2 – The “X”
The second improper method is the X link that appears in the upper-right hand corner of the web part when the page is in edit mode.

Why These Are Bad Practices…
While I do not blame anyone for using this method, as we have all come to understand that most of the time, clicking on the X or going to File > Close within a regular application will close out the program, SharePoint adds a different meaning to these. As I mentioned in the prior sentence – I said most of the time, meaning that SharePoint treats these actions similar to, say, Windows Live Messenger. When you click the X in the top-right corner of the screen (of your contact list), it minimizes the application to the system tray, so it is still running and taking up system resources, you no longer see the window on your screen.

The X and Close options for SharePoint web parts behave in much the same fashion. When either of those options are used, the web part is indeed closed, and removed from your view, however, just like with Windows Live Messenger, it just removes it from view, however, each time the page is loaded, that web part is still loaded onto the page, however, it is not viewable, thus, taking up resources to render the web part, as well as adding addition download time to that page.

While it is not immediately apparent how to remove those for good, or show them back again on the page, there are ways to do so.

Viewing Web Parts Which Have Been Closed
To view which web parts have been closed on a page, we’ll utilize a an application page called Web Part Page Maintenance page. This page is not accessible from the Site Settings page or anywhere else in the UI by default, however it is surfaced if a web part on a specific page has an error, and a link is then given on the resulting error message. However, you can easily get to this page by appending the following to the current ASPX page you are on.

Say for example, you are on a team site default.aspx page, so you would have a URL like the following in your address bar:


By appending ?contents=1 to default.aspx, you can access the Web Part Page Maintenance page, like so:


You will then see a page like this:


In this list you can see each of the web parts that are on the page, the type of web part that they are, and most importantly (for this post), the last column, which shows you if the web part is open on the page or not.

If you use the two "improper” methods described above, this field will list the value of “No”.

This screen is also very handy for removing any closed web parts (or any others for that matter). To do so, check the box next to the web parts that are to be removed, and then click the Delete option within the toolbar above.


How to Properly Delete a Web Part from a Web Part Page
Now that we’ve outlined the issues, and how to recover from them. In addition to the ability to delete web parts from the web part page by using the Web Part Page Maintenance page as described above, the easiest way to properly remove a web part from the page is to put the page into edit mode (Site Actions > Edit Page), using the web part menu, and selecting Delete

This will remove the web part from the page for good.

While a few minor web parts, such as a lightweight Content Editor Web Part, and the default Image Web Part (created by default for Team and Blank site templates) will not be a huge performance hit, and will be barely noticeable, if at all. The real issue lies with large list views, data view web parts that roll-up information, or other web parts which can be memory and CPU intensive to run, such as a third party list roll-up web part that queries hundreds, or even thousands if lists. If these web parts are not removed from the page, and you have a few of them closed on there, the performance of that web part page, possibly the server itself will be affected.


About Geoff Varosky
Geoff Varosky is a Senior Architect for Insight, based out of Watertown, MA. He has been architecting and developing web based applications his entire career, and has been working with SharePoint for the past 15 years. Geoff is an active member of the SharePoint community, Co-Founder and Co-Organizer of the Boston Area SharePoint Users Group, co-founder for the Boston Office 365 Users Group, co-organizer for SharePoint Saturday Boston and speaks regularly at SharePoint events and user groups.

One Response to How to Properly Remove a Web Part from a Web Part Page

  1. Iggy says:

    With my own custom webparts, when they are closed, the code executes upto the webpart constructor. The Onit, OnLoad methods don\’t get executed. I confirm this by debugging on a SharePoint 2007 server. Is this not the case with other OOTB and third party webparts?My custom webpart inherits from System.Web.UI.WebControls.WebParts.WebPart.

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 )

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

%d bloggers like this: